track-cli 4.1.0 → 4.2.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.
@@ -1,6 +1,6 @@
1
1
  import * as dntShim from "../../_dnt.shims.js";
2
2
  import { CONFIG_FILE_PATH, load as loadConfig } from "../shared/config.js";
3
- import { CantReadFile, NewFilesNotAllowed } from "../shared/errors.js";
3
+ import { CantReadFile, NewFilesNotAllowed, RejectNewFilesInTestFolder, RejectTooLongFilepath } from "../shared/errors.js";
4
4
  import { pathsToFilenameSet, toNativeStyle } from "../shared/file.js";
5
5
  import { getCommonChallengeContext, listFileNames, printWorkingFileSet, trackClientFromConfig, } from "../shared/mod.js";
6
6
  import { FileListType } from "../shared/types.js";
@@ -20,6 +20,17 @@ export async function add(filePaths) {
20
20
  // Don't allow the config file to be added
21
21
  existingPaths.add(CONFIG_FILE_PATH);
22
22
  const pathsToAdd = Array.from(requestedPaths).filter((p) => !existingPaths.has(p));
23
+ // Files in test folder are not allowed
24
+ const filesInTestFolder = pathsToAdd.filter(v => v.startsWith("test/"));
25
+ if (filesInTestFolder.length > 0) {
26
+ throw new RejectNewFilesInTestFolder(filesInTestFolder);
27
+ }
28
+ // Reject long filepath
29
+ // https://givery.slack.com/archives/C05RABF6KU3/p1772069298650949
30
+ const longFilepaths = pathsToAdd.filter(v => v.length > 150);
31
+ if (longFilepaths.length > 0) {
32
+ throw new RejectTooLongFilepath(longFilepaths);
33
+ }
23
34
  const addedFiles = listFileNames(codingContext, FileListType.UserAddedFiles)
24
35
  .concat(pathsToAdd);
25
36
  const updatedFiles = {};
@@ -8,7 +8,6 @@ import { EnvSettings, FileListType, } from "../shared/types.js";
8
8
  import * as colors from "../../deps/deno.land/std@0.195.0/fmt/colors.js";
9
9
  import { exists } from "../../deps/deno.land/std@0.195.0/fs/mod.js";
10
10
  import { FileNotFound } from "../shared/errors.js";
11
- const MAX_MEMORY_FOR_TEST = 512 * 1024 * 1024; // 512 MB
12
11
  export async function run(options) {
13
12
  const config = await loadConfig();
14
13
  const api = trackClientFromConfig(config);
@@ -26,6 +25,7 @@ export async function run(options) {
26
25
  cacheDirs: envConfig.cacheDirs,
27
26
  username: envConfig.username,
28
27
  baseDir: envConfig.baseDir,
28
+ keepContainer: true,
29
29
  });
30
30
  const envVars = Object.assign({}, envConfig.variables);
31
31
  envVars["CHALLENGE_LANGUAGE"] = codingContext.challengeLanguage;
@@ -91,7 +91,6 @@ export async function run(options) {
91
91
  files: buildRan ? [] : files,
92
92
  envVars: {},
93
93
  tarballUrls: buildRan ? [] : codingContext.tarballUrls,
94
- memoryBytes: MAX_MEMORY_FOR_TEST,
95
94
  };
96
95
  const scoreCounter = new CountPassingLineHandler();
97
96
  const runDoneData = await orca.simpleRunCommand(runCmd, scoreCounter);
package/esm/src/meta.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare const VERSION = "4.1.0";
1
+ export declare const VERSION = "4.2.0-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.1.0";
4
+ export const VERSION = "4.2.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) {
@@ -15,6 +15,7 @@ export type PrepareCommand = {
15
15
  cacheDirs: string[];
16
16
  username?: string;
17
17
  baseDir?: string;
18
+ keepContainer?: boolean;
18
19
  };
19
20
  export type SimpleRunCommand = {
20
21
  id: string;
@@ -79,6 +79,14 @@ export declare class FileMissingOrOutsideDirectory extends TrackError {
79
79
  export declare class NewFilesNotAllowed extends TrackError {
80
80
  constructor();
81
81
  }
82
+ export declare class RejectNewFilesInTestFolder extends TrackError {
83
+ fileNames: string[];
84
+ constructor(fileNames: string[]);
85
+ }
86
+ export declare class RejectTooLongFilepath extends TrackError {
87
+ fileNames: string[];
88
+ constructor(fileNames: string[]);
89
+ }
82
90
  export declare class DeleteFilesNotAllowed extends TrackError {
83
91
  constructor();
84
92
  }
@@ -222,6 +222,30 @@ export class NewFilesNotAllowed extends TrackError {
222
222
  this.name = "NewFilesNotAllowed";
223
223
  }
224
224
  }
225
+ export class RejectNewFilesInTestFolder extends TrackError {
226
+ constructor(fileNames) {
227
+ super(`New files under test folder are not allowed: ${fileNames.join(", ")}`);
228
+ Object.defineProperty(this, "fileNames", {
229
+ enumerable: true,
230
+ configurable: true,
231
+ writable: true,
232
+ value: fileNames
233
+ });
234
+ this.name = "RejectNewFilesInTestFolder";
235
+ }
236
+ }
237
+ export class RejectTooLongFilepath extends TrackError {
238
+ constructor(fileNames) {
239
+ super(`More than 150 characters in filepath are not allowed: ${fileNames.join(", ")}`);
240
+ Object.defineProperty(this, "fileNames", {
241
+ enumerable: true,
242
+ configurable: true,
243
+ writable: true,
244
+ value: fileNames
245
+ });
246
+ this.name = "RejectTooLongFilepath";
247
+ }
248
+ }
225
249
  export class DeleteFilesNotAllowed extends TrackError {
226
250
  constructor() {
227
251
  super("This challenge does not allow the deletion of files");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "track-cli",
3
- "version": "4.1.0",
3
+ "version": "4.2.0-rc2",
4
4
  "description": "A CLI for interacting with tracks.run and running code tests on track's servers",
5
5
  "repository": {
6
6
  "type": "git",