track-cli 3.0.0-rc → 3.0.0-rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/_dnt.shims.d.ts +6 -5
- package/esm/_dnt.shims.js +5 -5
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +1 -1
- package/esm/shim/prompts.d.ts +3 -0
- package/esm/shim/prompts.js +44 -0
- package/esm/src/meta.d.ts +1 -1
- package/esm/src/meta.js +1 -1
- package/esm/src/orca/client.js +1 -1
- package/esm/src/shared/mod.d.ts +4 -1
- package/esm/src/shared/mod.js +11 -4
- package/esm/src/track/client.js +1 -1
- package/package.json +3 -4
package/esm/_dnt.shims.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Deno } from "@deno/shim-deno";
|
|
2
2
|
export { Deno } from "@deno/shim-deno";
|
|
3
3
|
export { crypto, type Crypto, type SubtleCrypto, type AlgorithmIdentifier, type Algorithm, type RsaOaepParams, type BufferSource, type AesCtrParams, type AesCbcParams, type AesGcmParams, type CryptoKey, type KeyAlgorithm, type KeyType, type KeyUsage, type EcdhKeyDeriveParams, type HkdfParams, type HashAlgorithmIdentifier, type Pbkdf2Params, type AesDerivedKeyParams, type HmacImportParams, type JsonWebKey, type RsaOtherPrimesInfo, type KeyFormat, type RsaHashedKeyGenParams, type RsaKeyGenParams, type BigInteger, type EcKeyGenParams, type NamedCurve, type CryptoKeyPair, type AesKeyGenParams, type HmacKeyGenParams, type RsaHashedImportParams, type EcKeyImportParams, type AesKeyAlgorithm, type RsaPssParams, type EcdsaParams } from "@deno/shim-crypto";
|
|
4
|
-
export { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
5
4
|
import { fetch, File, FormData, Headers, Request, Response } from "undici";
|
|
6
5
|
export { fetch, File, FormData, Headers, Request, Response, type BodyInit, type HeadersInit, type RequestInit, type ResponseInit } from "undici";
|
|
7
|
-
|
|
6
|
+
import { alert, confirm, prompt } from "./shim/prompts.js";
|
|
7
|
+
export { alert, confirm, prompt } from "./shim/prompts.js";
|
|
8
|
+
export declare const dntGlobalThis: Omit<typeof globalThis, "Deno" | "crypto" | "fetch" | "File" | "FormData" | "Headers" | "Request" | "Response" | "alert" | "confirm" | "prompt"> & {
|
|
8
9
|
Deno: typeof Deno;
|
|
9
10
|
crypto: import("@deno/shim-crypto").Crypto;
|
|
10
|
-
alert: (message?: any) => void;
|
|
11
|
-
confirm: (message?: string | undefined) => boolean;
|
|
12
|
-
prompt: (message?: string | undefined, _default?: string | undefined) => string | null;
|
|
13
11
|
fetch: typeof fetch;
|
|
14
12
|
File: typeof File;
|
|
15
13
|
FormData: typeof FormData;
|
|
16
14
|
Headers: typeof Headers;
|
|
17
15
|
Request: typeof Request;
|
|
18
16
|
Response: typeof Response;
|
|
17
|
+
alert: typeof alert;
|
|
18
|
+
confirm: typeof confirm;
|
|
19
|
+
prompt: typeof prompt;
|
|
19
20
|
};
|
package/esm/_dnt.shims.js
CHANGED
|
@@ -2,22 +2,22 @@ import { Deno } from "@deno/shim-deno";
|
|
|
2
2
|
export { Deno } from "@deno/shim-deno";
|
|
3
3
|
import { crypto } from "@deno/shim-crypto";
|
|
4
4
|
export { crypto } from "@deno/shim-crypto";
|
|
5
|
-
import { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
6
|
-
export { alert, confirm, prompt } from "@deno/shim-prompts";
|
|
7
5
|
import { fetch, File, FormData, Headers, Request, Response } from "undici";
|
|
8
6
|
export { fetch, File, FormData, Headers, Request, Response } from "undici";
|
|
7
|
+
import { alert, confirm, prompt } from "./shim/prompts.js";
|
|
8
|
+
export { alert, confirm, prompt } from "./shim/prompts.js";
|
|
9
9
|
const dntGlobals = {
|
|
10
10
|
Deno,
|
|
11
11
|
crypto,
|
|
12
|
-
alert,
|
|
13
|
-
confirm,
|
|
14
|
-
prompt,
|
|
15
12
|
fetch,
|
|
16
13
|
File,
|
|
17
14
|
FormData,
|
|
18
15
|
Headers,
|
|
19
16
|
Request,
|
|
20
17
|
Response,
|
|
18
|
+
alert,
|
|
19
|
+
confirm,
|
|
20
|
+
prompt,
|
|
21
21
|
};
|
|
22
22
|
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
23
23
|
// deno-lint-ignore ban-types
|
|
@@ -35,7 +35,7 @@ export declare class TableLayout {
|
|
|
35
35
|
* original cell.
|
|
36
36
|
*/
|
|
37
37
|
protected spanRows(rows: Array<IRow>): Row<Cell>[];
|
|
38
|
-
protected getDeleteCount(rows: Array<Array<unknown>>, rowIndex: number, colIndex: number):
|
|
38
|
+
protected getDeleteCount(rows: Array<Array<unknown>>, rowIndex: number, colIndex: number): 1 | 0;
|
|
39
39
|
/**
|
|
40
40
|
* Create a new row from existing row or cell array.
|
|
41
41
|
* @param row Original row.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Temporary fixed version of shims for prompts
|
|
2
|
+
// See original version: https://github.com/denoland/node_shims/blob/main/packages/shim-prompts
|
|
3
|
+
import * as dntShim from "../_dnt.shims.js";
|
|
4
|
+
import { readSync, writeSync } from "fs";
|
|
5
|
+
export function alert(message) {
|
|
6
|
+
dntShim.dntGlobalThis.alert(message);
|
|
7
|
+
writeSync(process.stdout.fd, new TextEncoder().encode(`${message} [Enter] `));
|
|
8
|
+
readlineSync();
|
|
9
|
+
}
|
|
10
|
+
export function confirm(message) {
|
|
11
|
+
writeSync(process.stdout.fd, new TextEncoder().encode(`${message} [y/N] `));
|
|
12
|
+
const result = readlineSync();
|
|
13
|
+
return ["y", "Y"].includes(result);
|
|
14
|
+
}
|
|
15
|
+
export function prompt(message, defaultValue = undefined) {
|
|
16
|
+
writeSync(process.stdout.fd, new TextEncoder().encode(`${message} ${defaultValue == null ? "" : `[${defaultValue}]`} `));
|
|
17
|
+
const result = readlineSync();
|
|
18
|
+
return result.length > 0 ? result : defaultValue ?? null;
|
|
19
|
+
}
|
|
20
|
+
function readlineSync() {
|
|
21
|
+
let line = "";
|
|
22
|
+
let char = "";
|
|
23
|
+
const buf = Buffer.alloc(1);
|
|
24
|
+
while (char !== "\r" && char !== "\n") {
|
|
25
|
+
line += char;
|
|
26
|
+
try {
|
|
27
|
+
const bytesRead = readSync(process.stdin.fd, buf, 0, 1, null);
|
|
28
|
+
if (bytesRead === 0) {
|
|
29
|
+
return line;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
if (err.code === "EOF") {
|
|
34
|
+
return line;
|
|
35
|
+
}
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
char = String(buf);
|
|
39
|
+
}
|
|
40
|
+
if (char === "\r") {
|
|
41
|
+
readSync(process.stdin.fd, buf, 0, 1, null);
|
|
42
|
+
}
|
|
43
|
+
return line;
|
|
44
|
+
}
|
package/esm/src/meta.d.ts
CHANGED
package/esm/src/meta.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as colors from "../deps/deno.land/std@0.195.0/fmt/colors.js";
|
|
2
2
|
// @ts-ignore: has no exported member
|
|
3
3
|
import { CookieJar, fetch } from "node-fetch-cookies";
|
|
4
|
-
export const VERSION = "3.0.0-
|
|
4
|
+
export const VERSION = "3.0.0-rc2";
|
|
5
5
|
export const DESCRIPTION = "A CLI for interacting with tracks.run and running code tests on track's servers";
|
|
6
6
|
const VERSION_RE = /^(\d+)\.(\d+)\.(\d+)(?:-?(.*))$/;
|
|
7
7
|
function parseSemver(s) {
|
package/esm/src/orca/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { OtherError } from "../shared/errors.js";
|
|
|
3
3
|
import { SnakeCase } from "../shared/mod.js";
|
|
4
4
|
import { green, red } from "../../deps/deno.land/std@0.195.0/fmt/colors.js";
|
|
5
5
|
import { EventEmitter } from "eventemitter3";
|
|
6
|
-
import ProxyAgent from "proxy-agent";
|
|
6
|
+
import { ProxyAgent } from "proxy-agent";
|
|
7
7
|
import WebSocket from "ws";
|
|
8
8
|
const RE_TAP_OK = new RegExp("^ok \\d+ ");
|
|
9
9
|
const RE_TAP_NG = new RegExp("^not ok \\d+ ");
|
package/esm/src/shared/mod.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ import { TrackClient } from "../track/client.js";
|
|
|
4
4
|
import { ApplicantExamForNoAuth, ChallengeResult, ChallengeSettings, CodingContext, ExamSession, ExamSessionChallenge, FileListType, ProgrammingLanguageInfo } from "../track/types.js";
|
|
5
5
|
import { CodingAnswers } from "../track/types.js";
|
|
6
6
|
export declare const _internals: {
|
|
7
|
-
prompt:
|
|
7
|
+
prompt: typeof dntShim.prompt;
|
|
8
|
+
scoreRatio: typeof scoreRatio;
|
|
8
9
|
};
|
|
9
10
|
export declare const HttpStatus: {
|
|
10
11
|
readonly OK: 200;
|
|
@@ -30,6 +31,7 @@ export declare const SnakeCase: {
|
|
|
30
31
|
from<T_1>(obj: T_1): T_1;
|
|
31
32
|
};
|
|
32
33
|
export declare function getCommonChallengeContext(): Promise<TrackCLIContext>;
|
|
34
|
+
declare function scoreRatio(editorScore: number | undefined, openTestcases: number | undefined): string;
|
|
33
35
|
export declare function printChallengeInfo(trackContext: TrackCLIContext): Promise<void>;
|
|
34
36
|
export declare function printWorkingFileSet(codingContext: CodingContext): void;
|
|
35
37
|
export declare function downloadChallengeFilesTo(codingContext: CodingContext, dest: string, api: TrackClient, applicantExamId: number, challengeResultId: number, showFileDiff: boolean, includeTarball: boolean): Promise<void>;
|
|
@@ -38,3 +40,4 @@ export type ArchiveExistingChallengeFilesOptions = {
|
|
|
38
40
|
selectedLanguage?: ProgrammingLanguageInfo;
|
|
39
41
|
};
|
|
40
42
|
export declare function archiveExistingChallengeFiles(orgName: string, challengePosition: number, options?: ArchiveExistingChallengeFilesOptions): Promise<void>;
|
|
43
|
+
export {};
|
package/esm/src/shared/mod.js
CHANGED
|
@@ -10,6 +10,7 @@ import { format as duration } from "../../deps/deno.land/std@0.195.0/fmt/duratio
|
|
|
10
10
|
import * as fs from "../../deps/deno.land/std@0.195.0/fs/mod.js";
|
|
11
11
|
export const _internals = {
|
|
12
12
|
prompt: dntShim.prompt,
|
|
13
|
+
scoreRatio: scoreRatio,
|
|
13
14
|
};
|
|
14
15
|
export const HttpStatus = {
|
|
15
16
|
OK: 200,
|
|
@@ -295,6 +296,15 @@ function getResultFromExamSession(examSession, challengeId) {
|
|
|
295
296
|
.results
|
|
296
297
|
.find((cr) => cr.challengeId === challengeId);
|
|
297
298
|
}
|
|
299
|
+
function scoreRatio(editorScore, openTestcases) {
|
|
300
|
+
// @ts-expect-error: isFinite(undefined) === false, isFinite(0) === true. See MDN
|
|
301
|
+
if (isFinite(editorScore) && openTestcases) {
|
|
302
|
+
return `\t${editorScore}/${openTestcases}`;
|
|
303
|
+
}
|
|
304
|
+
else {
|
|
305
|
+
return "\tN/A - Use 'track run' to save and run your submission";
|
|
306
|
+
}
|
|
307
|
+
}
|
|
298
308
|
export async function printChallengeInfo(trackContext) {
|
|
299
309
|
const { config, api, challengeResult: result } = trackContext;
|
|
300
310
|
const timeLeft = await api.timeLeft(config.applicantExamId, config.challengeResultId);
|
|
@@ -303,11 +313,8 @@ export async function printChallengeInfo(trackContext) {
|
|
|
303
313
|
const lastScoredAt = result.lastScoredAt
|
|
304
314
|
? ` (Ran at ${datetime.format(new Date(result.lastScoredAt), "yyyy-MM-dd HH:mm:ss")})`
|
|
305
315
|
: "";
|
|
306
|
-
const scoreRatio = (result.editorScore && trackContext.challenge.openTestcases)
|
|
307
|
-
? `\t${result.editorScore}/${trackContext.challenge.openTestcases}`
|
|
308
|
-
: "\tN/A - Use 'track run' to save and run your submission";
|
|
309
316
|
console.log(`Latest score${lastScoredAt}`);
|
|
310
|
-
console.log(colors.green(scoreRatio));
|
|
317
|
+
console.log(colors.green(scoreRatio(result.editorScore, trackContext.challenge.openTestcases)));
|
|
311
318
|
console.log();
|
|
312
319
|
printTimeLeft(timeLeft);
|
|
313
320
|
}
|
package/esm/src/track/client.js
CHANGED
|
@@ -3,7 +3,7 @@ import { HttpStatus } from "../shared/mod.js";
|
|
|
3
3
|
import { APIError, OtherError } from "../shared/errors.js";
|
|
4
4
|
// @ts-ignore: has no exported member
|
|
5
5
|
import { CookieJar, fetch } from "node-fetch-cookies";
|
|
6
|
-
import ProxyAgent from "proxy-agent";
|
|
6
|
+
import { ProxyAgent } from "proxy-agent";
|
|
7
7
|
export const FormType = {
|
|
8
8
|
URLEncoded: "urlencoded",
|
|
9
9
|
JSON: "json",
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"track": "./esm/src/main.js"
|
|
4
4
|
},
|
|
5
5
|
"name": "track-cli",
|
|
6
|
-
"version": "3.0.0-
|
|
6
|
+
"version": "3.0.0-rc2",
|
|
7
7
|
"description": "A CLI for interacting with tracks.run and running code tests on track's servers",
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"repository": {
|
|
@@ -20,16 +20,15 @@
|
|
|
20
20
|
"@hazae41/foras": "*",
|
|
21
21
|
"eventemitter3": "5.0.1",
|
|
22
22
|
"node-fetch-cookies": "2.0.4",
|
|
23
|
-
"proxy-agent": "
|
|
23
|
+
"proxy-agent": "6.3.0",
|
|
24
24
|
"tar": "*",
|
|
25
25
|
"ws": "7.4.6",
|
|
26
26
|
"@deno/shim-deno": "~0.16.1",
|
|
27
27
|
"@deno/shim-crypto": "~0.3.1",
|
|
28
|
-
"@deno/shim-prompts": "~0.1.0",
|
|
29
28
|
"undici": "^5.21.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@types/node": "^18.11.9",
|
|
33
32
|
"picocolors": "^1.0.0"
|
|
34
33
|
}
|
|
35
|
-
}
|
|
34
|
+
}
|