track-cli 4.0.0 → 4.0.1-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.
@@ -5,7 +5,7 @@ import { fetch, File, FormData, Headers, Request, Response } from "undici";
5
5
  export { fetch, File, FormData, Headers, Request, Response, type BodyInit, type HeadersInit, type RequestInit, type ResponseInit } from "undici";
6
6
  import { alert, confirm, prompt } from "./shim/prompts.js";
7
7
  export { alert, confirm, prompt } from "./shim/prompts.js";
8
- export declare const dntGlobalThis: Omit<typeof globalThis, "fetch" | "Request" | "Response" | "FormData" | "Headers" | "Deno" | "crypto" | "File" | "alert" | "confirm" | "prompt"> & {
8
+ export declare const dntGlobalThis: Omit<typeof globalThis, "fetch" | "Request" | "Response" | "FormData" | "Headers" | "File" | "crypto" | "Deno" | "alert" | "confirm" | "prompt"> & {
9
9
  Deno: typeof Deno;
10
10
  crypto: import("@deno/shim-crypto").Crypto;
11
11
  fetch: typeof fetch;
package/esm/_dnt.shims.js CHANGED
@@ -20,7 +20,6 @@ const dntGlobals = {
20
20
  prompt,
21
21
  };
22
22
  export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
23
- // deno-lint-ignore ban-types
24
23
  function createMergeProxy(baseObj, extObj) {
25
24
  return new Proxy(baseObj, {
26
25
  get(_target, prop, _receiver) {
@@ -3,7 +3,7 @@ import { Cell } from "./cell.js";
3
3
  import { TableLayout } from "./layout.js";
4
4
  import { Row } from "./row.js";
5
5
  /** Table representation. */
6
- class Table extends Array {
6
+ export class Table extends Array {
7
7
  constructor() {
8
8
  super(...arguments);
9
9
  Object.defineProperty(this, "options", {
@@ -234,4 +234,3 @@ Object.defineProperty(Table, "_chars", {
234
234
  writable: true,
235
235
  value: { ...border }
236
236
  });
237
- export { Table };
@@ -5,6 +5,7 @@ import { isEmptyDirectory, pathsToFilenameSet, toNativeStyle, } from "../shared/
5
5
  import { getCommonChallengeContext, listFileNames, printWorkingFileSet, trackClientFromConfig, } from "../shared/mod.js";
6
6
  import { FileListType } from "../shared/types.js";
7
7
  import * as colors from "../../deps/deno.land/std@0.195.0/fmt/colors.js";
8
+ import { exists } from "../../deps/deno.land/std@0.195.0/fs/mod.js";
8
9
  export async function remove(filePaths, options) {
9
10
  const config = await loadConfig();
10
11
  const api = trackClientFromConfig(config);
@@ -14,7 +15,7 @@ export async function remove(filePaths, options) {
14
15
  }
15
16
  const requestedPathsToDelete = await pathsToFilenameSet(filePaths, {
16
17
  recursive: options?.recursive,
17
- allowNonExistent: false,
18
+ allowNonExistent: true,
18
19
  });
19
20
  const filesToDelete = [];
20
21
  const filesToKeep = [];
@@ -38,7 +39,7 @@ export async function remove(filePaths, options) {
38
39
  updatedFiles: {},
39
40
  };
40
41
  await api.saveFiles(saveFilesRequest);
41
- await Promise.all(filesToDelete.map((file) => dntShim.Deno.remove(file)))
42
+ await Promise.all(filesToDelete.map((file) => exists(file).then((e) => e ? dntShim.Deno.remove(file) : Promise.resolve())))
42
43
  .catch((e) => Promise.reject(new OtherError(`An error occurred while deleting files: ${e}`)));
43
44
  // For each file to delete, walk the file's parents and delete directories
44
45
  // if they are empty, stopping at the first non-empty one.
@@ -6,6 +6,8 @@ import { EnvSettings, FileListType, } from "../shared/types.js";
6
6
  import { OrcaClient } from "../orca/client.js";
7
7
  import { FileType } from "../orca/types.js";
8
8
  import * as colors from "../../deps/deno.land/std@0.195.0/fmt/colors.js";
9
+ import { exists } from "../../deps/deno.land/std@0.195.0/fs/mod.js";
10
+ import { FileNotFound } from "../shared/errors.js";
9
11
  const MAX_MEMORY_FOR_TEST = 512 * 1024 * 1024; // 512 MB
10
12
  export async function run(options) {
11
13
  const config = await loadConfig();
@@ -127,11 +129,21 @@ async function getAllEditableFileContent(context) {
127
129
  const result = {};
128
130
  for (const filePath of listFileNames(context, FileListType.Editable)) {
129
131
  try {
130
- const fileStr = await dntShim.Deno.readFile(filePath);
131
- result[filePath] = new TextDecoder().decode(fileStr);
132
+ if (await exists(filePath)) {
133
+ const fileStr = await dntShim.Deno.readFile(filePath);
134
+ result[filePath] = new TextDecoder().decode(fileStr);
135
+ }
136
+ else {
137
+ throw new FileNotFound(filePath);
138
+ }
132
139
  }
133
- catch (_e) {
134
- throw new CantReadFile(filePath);
140
+ catch (e) {
141
+ if (e instanceof FileNotFound) {
142
+ throw e;
143
+ }
144
+ else {
145
+ throw new CantReadFile(filePath);
146
+ }
135
147
  }
136
148
  }
137
149
  return result;
package/esm/src/meta.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "4.0.0";
1
+ export declare const VERSION = "4.0.1-rc2";
2
2
  export declare const DESCRIPTION = "A CLI for interacting with tracks.run and running code tests on track's servers";
3
3
  export declare function checkUpdates(): Promise<boolean>;
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 = "4.0.0";
4
+ export const VERSION = "4.0.1-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) {
@@ -62,6 +62,10 @@ export declare class CantReadFile extends TrackError {
62
62
  fileName: string;
63
63
  constructor(fileName: string);
64
64
  }
65
+ export declare class FileNotFound extends TrackError {
66
+ fileName: string;
67
+ constructor(fileName: string);
68
+ }
65
69
  export declare class FileMissingOrOutsideDirectory extends TrackError {
66
70
  fileName: string;
67
71
  constructor(fileName: string);
@@ -169,7 +169,7 @@ export class BadTarballURL extends TrackError {
169
169
  // }
170
170
  export class CantReadFile extends TrackError {
171
171
  constructor(fileName) {
172
- super(`Could not read file - ${fileName} - Please make sure it is saved with a UTF-8 encoding.`);
172
+ super(`Could not read file: ${fileName} - Please make sure it is saved with a UTF-8 encoding.`);
173
173
  Object.defineProperty(this, "fileName", {
174
174
  enumerable: true,
175
175
  configurable: true,
@@ -179,6 +179,18 @@ export class CantReadFile extends TrackError {
179
179
  this.name = "CantReadFile";
180
180
  }
181
181
  }
182
+ export class FileNotFound extends TrackError {
183
+ constructor(fileName) {
184
+ super(`File not found: ${fileName} - If you deleted this file, run 'track rm' command.`);
185
+ Object.defineProperty(this, "fileName", {
186
+ enumerable: true,
187
+ configurable: true,
188
+ writable: true,
189
+ value: fileName
190
+ });
191
+ this.name = "FileNotFound";
192
+ }
193
+ }
182
194
  export class FileMissingOrOutsideDirectory extends TrackError {
183
195
  constructor(fileName) {
184
196
  super(`File missing or located outside of the challenge directory - ${fileName}`);
@@ -15,9 +15,12 @@ export const _internals = {
15
15
  export async function pathsToFilenameSet(paths, options) {
16
16
  const files = [];
17
17
  const root = options?.root ?? dntShim.Deno.cwd();
18
- for (const p of paths.map((p) => `${root}/${p}`)) {
18
+ for (const p of paths.map((p) => path.resolve(root, p))) {
19
19
  const f = await stat(p);
20
20
  const rp = toNixStyle(path.relative(root, p));
21
+ if (rp.startsWith("..")) {
22
+ continue;
23
+ }
21
24
  if (options?.recursive && f) {
22
25
  const dirFiles = await getAllDirFiles(p);
23
26
  dirFiles.forEach((file) => files.push(toNixStyle(path.relative(root, file))));
package/package.json CHANGED
@@ -1,21 +1,21 @@
1
1
  {
2
- "bin": {
3
- "track": "./esm/src/main.js"
4
- },
5
2
  "name": "track-cli",
6
- "version": "4.0.0",
3
+ "version": "4.0.1-rc2",
7
4
  "description": "A CLI for interacting with tracks.run and running code tests on track's servers",
8
- "license": "MIT",
9
5
  "repository": {
10
6
  "type": "git",
11
7
  "url": "git+https://github.com/givery-technology/track-cli.git"
12
8
  },
9
+ "license": "MIT",
13
10
  "bugs": {
14
11
  "url": "https://github.com/givery-technology/track-cli/issues"
15
12
  },
16
13
  "scripts": {
17
14
  "test": "node test_runner.js"
18
15
  },
16
+ "bin": {
17
+ "track": "./esm/src/main.js"
18
+ },
19
19
  "dependencies": {
20
20
  "@hazae41/foras": "2.0.8",
21
21
  "eventemitter3": "5.0.1",
@@ -23,12 +23,13 @@
23
23
  "proxy-agent": "6.3.0",
24
24
  "tar": "*",
25
25
  "ws": "7.4.6",
26
- "@deno/shim-deno": "~0.16.1",
26
+ "@deno/shim-deno": "~0.17.0",
27
27
  "@deno/shim-crypto": "~0.3.1",
28
- "undici": "^5.21.0"
28
+ "undici": "^5.27.2"
29
29
  },
30
30
  "devDependencies": {
31
- "@types/node": "^18.11.9",
31
+ "@types/node": "^20.9.0",
32
32
  "picocolors": "^1.0.0"
33
- }
33
+ },
34
+ "_generatedBy": "dnt@0.39.0"
34
35
  }