track-cli 4.0.3 → 4.1.0-rc1

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.
Files changed (90) hide show
  1. package/esm/_dnt.shims.d.ts +1 -1
  2. package/esm/_dnt.test_shims.d.ts +20 -0
  3. package/esm/_dnt.test_shims.js +77 -0
  4. package/esm/deps/deno.land/std@0.195.0/_util/diff.d.ts +26 -0
  5. package/esm/deps/deno.land/std@0.195.0/_util/diff.js +311 -0
  6. package/esm/deps/deno.land/std@0.195.0/assert/_constants.d.ts +1 -0
  7. package/esm/deps/deno.land/std@0.195.0/assert/_constants.js +2 -0
  8. package/esm/deps/deno.land/std@0.195.0/assert/_format.d.ts +1 -0
  9. package/esm/deps/deno.land/std@0.195.0/assert/_format.js +23 -0
  10. package/esm/deps/deno.land/std@0.195.0/assert/assert_almost_equals.d.ts +18 -0
  11. package/esm/deps/deno.land/std@0.195.0/assert/assert_almost_equals.js +32 -0
  12. package/esm/deps/deno.land/std@0.195.0/assert/assert_array_includes.d.ts +14 -0
  13. package/esm/deps/deno.land/std@0.195.0/assert/assert_array_includes.js +38 -0
  14. package/esm/deps/deno.land/std@0.195.0/assert/assert_equals.d.ts +17 -0
  15. package/esm/deps/deno.land/std@0.195.0/assert/assert_equals.js +45 -0
  16. package/esm/deps/deno.land/std@0.195.0/assert/assert_exists.d.ts +5 -0
  17. package/esm/deps/deno.land/std@0.195.0/assert/assert_exists.js +14 -0
  18. package/esm/deps/deno.land/std@0.195.0/assert/assert_false.d.ts +4 -0
  19. package/esm/deps/deno.land/std@0.195.0/assert/assert_false.js +7 -0
  20. package/esm/deps/deno.land/std@0.195.0/assert/assert_instance_of.d.ts +8 -0
  21. package/esm/deps/deno.land/std@0.195.0/assert/assert_instance_of.js +38 -0
  22. package/esm/deps/deno.land/std@0.195.0/assert/assert_is_error.d.ts +7 -0
  23. package/esm/deps/deno.land/std@0.195.0/assert/assert_is_error.js +26 -0
  24. package/esm/deps/deno.land/std@0.195.0/assert/assert_match.d.ts +5 -0
  25. package/esm/deps/deno.land/std@0.195.0/assert/assert_match.js +13 -0
  26. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_equals.d.ts +14 -0
  27. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_equals.js +37 -0
  28. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_instance_of.d.ts +5 -0
  29. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_instance_of.js +14 -0
  30. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_match.d.ts +5 -0
  31. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_match.js +14 -0
  32. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_strict_equals.d.ts +11 -0
  33. package/esm/deps/deno.land/std@0.195.0/assert/assert_not_strict_equals.js +20 -0
  34. package/esm/deps/deno.land/std@0.195.0/assert/assert_object_match.d.ts +5 -0
  35. package/esm/deps/deno.land/std@0.195.0/assert/assert_object_match.js +78 -0
  36. package/esm/deps/deno.land/std@0.195.0/assert/assert_rejects.d.ts +64 -0
  37. package/esm/deps/deno.land/std@0.195.0/assert/assert_rejects.js +50 -0
  38. package/esm/deps/deno.land/std@0.195.0/assert/assert_strict_equals.d.ts +23 -0
  39. package/esm/deps/deno.land/std@0.195.0/assert/assert_strict_equals.js +60 -0
  40. package/esm/deps/deno.land/std@0.195.0/assert/assert_string_includes.d.ts +5 -0
  41. package/esm/deps/deno.land/std@0.195.0/assert/assert_string_includes.js +13 -0
  42. package/esm/deps/deno.land/std@0.195.0/assert/assert_throws.d.ts +54 -0
  43. package/esm/deps/deno.land/std@0.195.0/assert/assert_throws.js +44 -0
  44. package/esm/deps/deno.land/std@0.195.0/assert/equal.d.ts +6 -0
  45. package/esm/deps/deno.land/std@0.195.0/assert/equal.js +102 -0
  46. package/esm/deps/deno.land/std@0.195.0/assert/fail.d.ts +4 -0
  47. package/esm/deps/deno.land/std@0.195.0/assert/fail.js +9 -0
  48. package/esm/deps/deno.land/std@0.195.0/assert/mod.d.ts +32 -0
  49. package/esm/deps/deno.land/std@0.195.0/assert/mod.js +33 -0
  50. package/esm/deps/deno.land/std@0.195.0/assert/unimplemented.d.ts +2 -0
  51. package/esm/deps/deno.land/std@0.195.0/assert/unimplemented.js +7 -0
  52. package/esm/deps/deno.land/std@0.195.0/assert/unreachable.d.ts +2 -0
  53. package/esm/deps/deno.land/std@0.195.0/assert/unreachable.js +6 -0
  54. package/esm/deps/deno.land/std@0.195.0/testing/_test_suite.d.ts +70 -0
  55. package/esm/deps/deno.land/std@0.195.0/testing/_test_suite.js +321 -0
  56. package/esm/deps/deno.land/std@0.195.0/testing/asserts.d.ts +329 -0
  57. package/esm/deps/deno.land/std@0.195.0/testing/asserts.js +330 -0
  58. package/esm/deps/deno.land/std@0.195.0/testing/bdd.d.ts +440 -0
  59. package/esm/deps/deno.land/std@0.195.0/testing/bdd.js +215 -0
  60. package/esm/deps/deno.land/std@0.195.0/testing/mock.d.ts +110 -0
  61. package/esm/deps/deno.land/std@0.195.0/testing/mock.js +746 -0
  62. package/esm/src/action/clone.js +4 -3
  63. package/esm/src/action/frontend-template-switch.d.ts +1 -0
  64. package/esm/src/action/frontend-template-switch.js +56 -0
  65. package/esm/src/action/frontend-template.d.ts +2 -0
  66. package/esm/src/action/frontend-template.js +12 -0
  67. package/esm/src/main.js +9 -2
  68. package/esm/src/meta.d.ts +1 -1
  69. package/esm/src/meta.js +108 -25
  70. package/esm/src/orca/client.js +1 -1
  71. package/esm/src/shared/config.d.ts +1 -0
  72. package/esm/src/shared/file.d.ts +1 -0
  73. package/esm/src/shared/file.js +32 -0
  74. package/esm/src/shared/mod.d.ts +1 -1
  75. package/esm/src/shared/mod.js +10 -2
  76. package/esm/src/shared/types.d.ts +15 -0
  77. package/esm/src/shared/types.js +1 -0
  78. package/esm/src/track/client.d.ts +4 -1
  79. package/esm/src/track/test.d.ts +5 -2
  80. package/esm/src/track/test.js +18 -2
  81. package/esm/src/track/training.d.ts +4 -1
  82. package/esm/src/track/training.js +9 -0
  83. package/esm/test/shared/config_test.d.ts +1 -0
  84. package/esm/test/shared/config_test.js +57 -0
  85. package/esm/test/shared/file_test.d.ts +1 -0
  86. package/esm/test/shared/file_test.js +265 -0
  87. package/esm/test/shared/mod_test.d.ts +1 -0
  88. package/esm/test/shared/mod_test.js +353 -0
  89. package/package.json +2 -1
  90. package/test_runner.js +186 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "track-cli",
3
- "version": "4.0.3",
3
+ "version": "4.1.0-rc1",
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",
@@ -19,6 +19,7 @@
19
19
  "dependencies": {
20
20
  "@hazae41/foras": "2.0.8",
21
21
  "eventemitter3": "5.0.1",
22
+ "jszip": "3.10.1",
22
23
  "node-fetch-cookies": "2.0.4",
23
24
  "proxy-agent": "6.3.0",
24
25
  "tar": "6.1.13",
package/test_runner.js ADDED
@@ -0,0 +1,186 @@
1
+ const pc = require("picocolors");
2
+ const process = require("process");
3
+ const { pathToFileURL } = require("url");
4
+ const { testDefinitions } = require("@deno/shim-deno/test-internals");
5
+ const filePaths = [
6
+ "src/track/test.js",
7
+ "test/shared/config_test.js",
8
+ "test/shared/file_test.js",
9
+ "test/shared/mod_test.js",
10
+ ];
11
+ async function main() {
12
+ const testContext = {
13
+ process,
14
+ pc,
15
+ };
16
+ for (const [i, filePath] of filePaths.entries()) {
17
+ if (i > 0) {
18
+ console.log("");
19
+ }
20
+ const esmPath = "./esm/" + filePath;
21
+ console.log("\nRunning tests in " + pc.underline(esmPath) + "...\n");
22
+ process.chdir(__dirname + "/esm");
23
+ const esmTestContext = {
24
+ origin: pathToFileURL(filePath).toString(),
25
+ ...testContext,
26
+ };
27
+ await import(esmPath);
28
+ await runTestDefinitions(testDefinitions.splice(0, testDefinitions.length), esmTestContext);
29
+ }
30
+ }
31
+ async function runTestDefinitions(testDefinitions, options) {
32
+ const testFailures = [];
33
+ for (const definition of testDefinitions) {
34
+ options.process.stdout.write("test " + definition.name + " ...");
35
+ if (definition.ignore) {
36
+ options.process.stdout.write(` ${options.pc.gray("ignored")}\n`);
37
+ continue;
38
+ }
39
+ const context = getTestContext(definition, undefined);
40
+ let pass = false;
41
+ try {
42
+ await definition.fn(context);
43
+ if (context.hasFailingChild) {
44
+ testFailures.push({
45
+ name: definition.name,
46
+ err: new Error("Had failing test step.")
47
+ });
48
+ }
49
+ else {
50
+ pass = true;
51
+ }
52
+ }
53
+ catch (err) {
54
+ testFailures.push({
55
+ name: definition.name,
56
+ err
57
+ });
58
+ }
59
+ const testStepOutput = context.getOutput();
60
+ if (testStepOutput.length > 0) {
61
+ options.process.stdout.write(testStepOutput);
62
+ }
63
+ else {
64
+ options.process.stdout.write(" ");
65
+ }
66
+ options.process.stdout.write(getStatusText(pass ? "ok" : "fail"));
67
+ options.process.stdout.write("\n");
68
+ }
69
+ if (testFailures.length > 0) {
70
+ options.process.stdout.write("\nFAILURES");
71
+ for (const failure of testFailures) {
72
+ options.process.stdout.write("\n\n");
73
+ options.process.stdout.write(failure.name + "\n");
74
+ options.process.stdout.write(indentText((failure.err?.stack ?? failure.err).toString(), 1));
75
+ }
76
+ options.process.exit(1);
77
+ }
78
+ function getTestContext(definition, parent) {
79
+ return {
80
+ name: definition.name,
81
+ parent,
82
+ origin: options.origin,
83
+ /** @type {any} */ err: undefined,
84
+ status: "ok",
85
+ children: [],
86
+ get hasFailingChild() {
87
+ return this.children.some((c) => c.status === "fail" || c.status === "pending");
88
+ },
89
+ getOutput() {
90
+ let output = "";
91
+ if (this.parent) {
92
+ output += "test " + this.name + " ...";
93
+ }
94
+ if (this.children.length > 0) {
95
+ output += "\n" + this.children.map((c) => indentText(c.getOutput(), 1)).join("\n") + "\n";
96
+ }
97
+ else if (!this.err) {
98
+ output += " ";
99
+ }
100
+ if (this.parent && this.err) {
101
+ output += "\n";
102
+ }
103
+ if (this.err) {
104
+ output += indentText((this.err.stack ?? this.err).toString(), 1);
105
+ if (this.parent) {
106
+ output += "\n";
107
+ }
108
+ }
109
+ if (this.parent) {
110
+ output += getStatusText(this.status);
111
+ }
112
+ return output;
113
+ },
114
+ async step(nameOrTestDefinition, fn) {
115
+ const definition = getDefinition();
116
+ const context = getTestContext(definition, this);
117
+ context.status = "pending";
118
+ this.children.push(context);
119
+ if (definition.ignore) {
120
+ context.status = "ignored";
121
+ return false;
122
+ }
123
+ try {
124
+ await definition.fn(context);
125
+ context.status = "ok";
126
+ if (context.hasFailingChild) {
127
+ context.status = "fail";
128
+ return false;
129
+ }
130
+ return true;
131
+ }
132
+ catch (err) {
133
+ context.status = "fail";
134
+ context.err = err;
135
+ return false;
136
+ }
137
+ /** @returns {TestDefinition} */ function getDefinition() {
138
+ if (typeof nameOrTestDefinition === "string") {
139
+ if (!(fn instanceof Function)) {
140
+ throw new TypeError("Expected function for second argument.");
141
+ }
142
+ return {
143
+ name: nameOrTestDefinition,
144
+ fn
145
+ };
146
+ }
147
+ else if (typeof nameOrTestDefinition === "object") {
148
+ return nameOrTestDefinition;
149
+ }
150
+ else {
151
+ throw new TypeError("Expected a test definition or name and function.");
152
+ }
153
+ }
154
+ }
155
+ };
156
+ }
157
+ function getStatusText(status) {
158
+ switch (status) {
159
+ case "ok":
160
+ return options.pc.green(status);
161
+ case "fail":
162
+ case "pending":
163
+ return options.pc.red(status);
164
+ case "ignored":
165
+ return options.pc.gray(status);
166
+ default:
167
+ {
168
+ const _assertNever = status;
169
+ return status;
170
+ }
171
+ }
172
+ }
173
+ function indentText(text, indentLevel) {
174
+ if (text === undefined) {
175
+ text = "[undefined]";
176
+ }
177
+ else if (text === null) {
178
+ text = "[null]";
179
+ }
180
+ else {
181
+ text = text.toString();
182
+ }
183
+ return text.split(/\r?\n/).map((line) => " ".repeat(indentLevel) + line).join("\n");
184
+ }
185
+ }
186
+ main();