Skip to content

Commit

Permalink
Latest version.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchallen committed Jul 22, 2021
1 parent ca891dd commit 4d08af9
Show file tree
Hide file tree
Showing 17 changed files with 84 additions and 60 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ allprojects {
}
subprojects {
group = "com.github.cs125-illinois.jeed"
version = "2021.7.1"
version = "2021.7.3"
tasks.withType<Test> {
useJUnitPlatform()
enableAssertions = true
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.7.0
version=2021.7.3
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
implementation("com.squareup.moshi:moshi:1.12.0")
implementation("org.ow2.asm:asm:9.2")
implementation("org.ow2.asm:asm-util:9.2")
implementation("org.slf4j:slf4j-api:1.7.31")
implementation("org.slf4j:slf4j-api:1.7.32")
implementation("ch.qos.logback:logback-classic:1.2.4")
implementation("io.github.microutils:kotlin-logging:2.0.10")
implementation("io.github.classgraph:classgraph:4.8.110")
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.7.0
version=2021.7.3
2 changes: 0 additions & 2 deletions js/demo/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ services:
- "LIMITS_EXECUTION_MAXEXTRATHREADS=8"
mongodb:
image: "bitnami/mongodb:4.4.3"
ports:
- "27017:27017"
logging:
driver: "none"
volumes:
Expand Down
2 changes: 1 addition & 1 deletion js/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"eslint-config-next": "11.0.1",
"prettier": "2.3.2",
"prettier-package-json": "2.6.0",
"prettier-plugin-organize-imports": "2.3.0",
"prettier-plugin-organize-imports": "2.3.3",
"sass": "1.35.2",
"typescript": "4.3.5"
}
Expand Down
8 changes: 6 additions & 2 deletions js/demo/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const JeedDemo: React.FC = () => {
response?.response
? terminalOutput(response.response)
: response?.error
? `<span class="error">${response?.error}</span>`
? { output: response?.error, level: "error" }
: undefined,
[response]
)
Expand Down Expand Up @@ -208,7 +208,11 @@ const JeedDemo: React.FC = () => {
</button>
</div>
</div>
{output !== undefined && <div className="output" dangerouslySetInnerHTML={{ __html: output }} />}
{output !== undefined && (
<div className="output">
<span className={output.level}>{output.output}</span>
</div>
)}
{response?.response && (
<AceEditor
readOnly
Expand Down
6 changes: 4 additions & 2 deletions js/demo/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ div.output {
background-color: #222222;
color: #dddddd;
padding: 8px;
max-height: calc(30em + 16px);
overflow: scroll;
span.error {
color: red;
}
span.success {
color: lightgreen;
span.warning {
color: goldenrod;
}
}
3 changes: 2 additions & 1 deletion js/output/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"eslint": "eslint src/**",
"ncu": "ncu",
"prepublish": "rimraf dist && tsc",
"start": "tsc -w",
"test": "JEED_SERVER=http://localhost:8888 ts-mocha --paths tests/index.spec.ts",
"prettier": "prettier -w --plugin=prettier-plugin-organize-imports . && prettier-package-json --write",
"watch": "tsc -w"
Expand All @@ -25,7 +26,7 @@
"npm-check-updates": "11.8.3",
"prettier": "2.3.2",
"prettier-package-json": "2.6.0",
"prettier-plugin-organize-imports": "2.3.0",
"prettier-plugin-organize-imports": "2.3.3",
"rimraf": "3.0.2",
"runtypes": "6.3.1",
"typescript": "4.3.5"
Expand Down
63 changes: 39 additions & 24 deletions js/output/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ export function getOriginalLine(request: Request, line: number, source?: string)
throw new Error(`Couldn't find line ${line} in source ${source}`)
}

export function terminalOutput(response: Response | undefined): string {
if (!response) {
return ""
}
export interface TerminalOutput {
output: string
level: "success" | "warning" | "error"
}
export function terminalOutput(response: Response): TerminalOutput {
const { request } = response
if (response.failed.snippet) {
const output = response.failed.snippet.errors
Expand All @@ -26,8 +27,11 @@ export function terminalOutput(response: Response | undefined): string {
})
.join("\n")
const errorCount = Object.keys(response.failed.snippet.errors).length
return `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`
return {
output: `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`,
level: "error",
}
} else if (response.failed.compilation || response.failed.kompilation) {
const output =
(response.failed.compilation || response.failed.kompilation)?.errors
Expand All @@ -52,8 +56,11 @@ ${originalLine ? originalLine + "\n" + new Array(column).join(" ") + "^" : ""}${
})
.join("\n") || ""
const errorCount = Object.keys((response.failed.compilation || response.failed.kompilation)?.errors || {}).length
return `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`
return {
output: `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`,
level: "error",
}
} else if (response.failed.checkstyle) {
const output =
response.failed.checkstyle?.errors
Expand All @@ -62,8 +69,11 @@ ${originalLine ? originalLine + "\n" + new Array(column).join(" ") + "^" : ""}${
})
.join("\n") || ""
const errorCount = Object.keys(response.failed.checkstyle?.errors || {}).length
return `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`
return {
output: `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`,
level: "error",
}
} else if (response.failed.ktlint) {
const output =
response.failed.ktlint?.errors
Expand All @@ -72,40 +82,47 @@ ${originalLine ? originalLine + "\n" + new Array(column).join(" ") + "^" : ""}${
})
.join("\n") || ""
const errorCount = Object.keys(response.failed.ktlint?.errors || {}).length
return `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`
return {
output: `${output}
${errorCount} error${errorCount > 1 ? "s" : ""}`,
level: "error",
}
} else if (response.failed.execution || response.failed.cexecution) {
const failed = response.failed.execution || response.failed.cexecution
if (failed?.classNotFound) {
return `Error: could not find class ${failed?.classNotFound}`
return { output: `Error: could not find class ${failed?.classNotFound}`, level: "error" }
} else if (failed?.methodNotFound) {
return `Error: could not find method ${failed?.methodNotFound}`
return { output: `Error: could not find method ${failed?.methodNotFound}`, level: "error" }
} else {
return `Something unexpected went wrong...`
return { output: `Something unexpected went wrong. Please report a bug.`, level: "error" }
}
}

if (Object.keys(response.failed).length === 0) {
if (response.completed.execution || response.completed.cexecution) {
let level: "success" | "error" | "warning" = "success"
const completed = response.completed.execution || response.completed.cexecution
const output = completed?.outputLines
? completed.outputLines.length > 0
? completed.outputLines.map(({ line }) => line)
: [`<span class="success">(Completed without output)</span>`]
: [`(Completed without output)`]
: []
if (response.completed.execution?.threw) {
level = "error"
output.push(response.completed.execution?.threw.stacktrace)
} else if (completed?.timeout) {
level = "error"
output.push("(Program timed out)")
}
if (completed?.truncatedLines || 0 > 0) {
level = "warning"
output.push(`(${completed?.truncatedLines} lines were truncated)`)
}
return output.join("\n")
return { output: output.join("\n"), level }
} else if (response.completed.checkstyle) {
return `<span class="success">No checkstyle errors found</span>`
return { output: `No checkstyle errors found`, level: "success" }
} else if (response.completed.ktlint) {
return `<span class="success">No ktlint errors found</span>`
return { output: `No ktlint errors found`, level: "success" }
} else if (response.completed.complexity) {
const results = response.completed.complexity.results
const output = []
Expand All @@ -124,7 +141,7 @@ ${originalLine ? originalLine + "\n" + new Array(column).join(" ") + "^" : ""}${
output.push(` ${methodName} has complexity ${method.complexity}`)
}
}
return output.join("\n")
return { output: output.join("\n"), level: "success" }
}
if (response.completed.features) {
const { results, allFeatures } = response.completed.features
Expand All @@ -143,10 +160,8 @@ ${originalLine ? originalLine + "\n" + new Array(column).join(" ") + "^" : ""}${
.sort()}`
)
}
return output.join("\n")
return { output: output.join("\n"), level: "success" }
}
}

console.error(`Nothing failed but no success result either...`)
return ""
throw Error("Can't generate output for this result")
}
2 changes: 1 addition & 1 deletion js/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@cs124/jeed-types": "2021.7.0",
"@cs124/koa-google-login": "2021.7.1",
"@koa/cors": "^3.1.0",
"@koa/router": "^10.0.0",
"@koa/router": "^10.1.0",
"http-terminator": "^3.0.0",
"koa": "^2.13.1",
"koa-body": "^4.2.0",
Expand Down
6 changes: 4 additions & 2 deletions js/proxy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import { String } from "runtypes"

const BACKEND = String.check(process.env.JEED_SERVER)

const { database } = String.guard(process.env.MONGODB) ? mongodbUri.parse(process.env.MONGODB) : { database: undefined }
const { username, database } = String.guard(process.env.MONGODB)
? mongodbUri.parse(process.env.MONGODB)
: { username: undefined, database: undefined }
const client = String.guard(process.env.MONGODB)
? MongoClient.connect(process.env.MONGODB, {
useNewUrlParser: true,
useUnifiedTopology: true,
authMechanism: "SCRAM-SHA-1",
...(username && { authMechanism: "SCRAM-SHA-1" }),
})
: undefined
const _collection = client?.then((c) => c.db(database).collection(process.env.MONGODB_COLLECTION || "jeed"))
Expand Down
11 changes: 6 additions & 5 deletions js/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@
"eslint": "eslint src/**",
"ncu": "ncu --dep dev,prod",
"prepublish": "rimraf dist && tsc",
"prettier": "prettier -w --plugin=prettier-plugin-organize-imports . && prettier-package-json --write",
"start": "tsc -w",
"test": "JEED_SERVER=http://localhost:8888 ts-mocha --paths tests/index.spec.ts",
"prettier": "prettier -w --plugin=prettier-plugin-organize-imports . && prettier-package-json --write",
"watch": "tsc -w"
},
"types": "dist/index.d.ts",
"peerDependencies": {
"react": ">= 16"
},
"dependencies": {
"@cs124/jeed-types": "2021.7.0"
},
"peerDependencies": {
"react": ">= 16"
},
"devDependencies": {
"@types/react": "^17.0.14",
"@typescript-eslint/eslint-plugin": "4.28.4",
Expand All @@ -29,7 +30,7 @@
"npm-check-updates": "11.8.3",
"prettier": "2.3.2",
"prettier-package-json": "2.6.0",
"prettier-plugin-organize-imports": "2.3.0",
"prettier-plugin-organize-imports": "2.3.3",
"react": "^17.0.2",
"rimraf": "3.0.2",
"runtypes": "6.3.1",
Expand Down
5 changes: 3 additions & 2 deletions js/types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"eslint": "eslint src/**",
"ncu": "ncu",
"prepublish": "rimraf dist && tsc",
"start": "tsc -w",
"test": "JEED_SERVER=http://localhost:8888 ts-mocha --paths tests/index.spec.ts",
"prettier": "prettier -w --plugin=prettier-plugin-organize-imports . && prettier-package-json --write",
"watch": "tsc -w"
Expand All @@ -22,7 +23,7 @@
"@types/js-yaml": "^4.0.2",
"@types/lodash": "^4.14.171",
"@types/mocha": "^8.2.3",
"@types/node": "^16.3.3",
"@types/node": "^16.4.0",
"@typescript-eslint/eslint-plugin": "4.28.4",
"@typescript-eslint/parser": "4.28.4",
"deep-diff": "^1.0.2",
Expand All @@ -35,7 +36,7 @@
"npm-check-updates": "11.8.3",
"prettier": "2.3.2",
"prettier-package-json": "2.6.0",
"prettier-plugin-organize-imports": "2.3.0",
"prettier-plugin-organize-imports": "2.3.3",
"rimraf": "3.0.2",
"runtypes": "6.3.1",
"ts-mocha": "^8.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ arguments:
maxExtraThreads: 4
maxOutputLines: 80
dryRun: false
waitForShutdown: true
waitForShutdown: true
24 changes: 12 additions & 12 deletions js/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1005,10 +1005,10 @@
dependencies:
vary "^1.1.2"

"@koa/router@^10.0.0":
version "10.0.0"
resolved "https://registry.yarnpkg.com/@koa/router/-/router-10.0.0.tgz#699115561afbd2740e2848ba299fc76b9e058ad6"
integrity sha512-z9ytrKWn/j/qUApMSJzZbUwkbLcN2ZXGq6UsqWkZb50Us+/Qpu0RwgZ6ytawVOhfFBZ1ai5iVWeD2Dcu0qcnJw==
"@koa/router@^10.1.0":
version "10.1.0"
resolved "https://registry.yarnpkg.com/@koa/router/-/router-10.1.0.tgz#bc1d0d9bb1051ece8b862eed9c91545e08e7a069"
integrity sha512-QZiCDn8Fd9vVN0qCWw81fToF5GMdtyPD04fIOHXiCCmXB6sznhjHMd3xbVS2ZxrgLWrcN8s6tIItEv0wuXt2Ow==
dependencies:
debug "^4.1.1"
http-errors "^1.7.3"
Expand Down Expand Up @@ -1420,10 +1420,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.2.tgz#655432817f83b51ac869c2d51dd8305fb8342e16"
integrity sha512-jJs9ErFLP403I+hMLGnqDRWT0RYKSvArxuBVh2veudHV7ifEC1WAmjJADacZ7mRbA2nWgHtn8xyECMAot0SkAw==

"@types/node@^16.3.3":
version "16.3.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.3.3.tgz#0c30adff37bbbc7a50eb9b58fae2a504d0d88038"
integrity sha512-8h7k1YgQKxKXWckzFCMfsIwn0Y61UK6tlD6y2lOb3hTOIMlK3t9/QwHOhc81TwU+RMf0As5fj7NPjroERCnejQ==
"@types/node@^16.4.0":
version "16.4.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.4.0.tgz#2c219eaa3b8d1e4d04f4dd6e40bc68c7467d5272"
integrity sha512-HrJuE7Mlqcjj+00JqMWpZ3tY8w7EUd+S0U3L1+PQSWiXZbOgyQDvi+ogoUxaHApPJq5diKxYBQwA3iIlNcPqOg==

"@types/normalize-package-data@^2.4.0":
version "2.4.1"
Expand Down Expand Up @@ -8599,10 +8599,10 @@ prettier-package-json@2.6.0, prettier-package-json@^2.6.0:
sort-object-keys "^1.1.3"
sort-order "^1.0.1"

prettier-plugin-organize-imports@2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-2.3.0.tgz#eb9d5043bc643992492bb7530b0f597d650f2ee7"
integrity sha512-U8wYUKvgBv+qJ3kZPI8VWfHbN0m/VxvMvWttLGKeFgcYzRzXmmRhP2FKN7IazOIZr9LFb6lSnLoPo3qwnDWUIw==
prettier-plugin-organize-imports@2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/prettier-plugin-organize-imports/-/prettier-plugin-organize-imports-2.3.3.tgz#6877bcf8ca02569198d8f419c954a0d90a95de15"
integrity sha512-PBOwQ8vEIB2b7B3gCuBG7D+dqsr1fsTR4TSAjNacRVdHJrD0yzgz9grOLPSyfwJm+NUTZLyWeHoZ+1mHaUrk+g==

prettier@2.3.2, prettier@^2.3.2:
version "2.3.2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version=2021.7.0
version=2021.7.2

0 comments on commit 4d08af9

Please sign in to comment.