track-cli 4.1.0-rc3 → 4.1.0
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/src/action/reset.js +21 -3
- package/esm/src/meta.d.ts +1 -1
- package/esm/src/meta.js +1 -1
- package/package.json +1 -1
package/esm/src/action/reset.js
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
1
|
import * as dntShim from "../../_dnt.shims.js";
|
|
2
2
|
import { load as loadConfig } from "../shared/config.js";
|
|
3
3
|
import { archiveExistingChallengeFiles, downloadChallengeFilesTo, getCommonChallengeContext, trackClientFromConfig, } from "../shared/mod.js";
|
|
4
|
+
import { ChallengeStyle, } from "../shared/types.js";
|
|
4
5
|
export async function reset() {
|
|
5
6
|
const config = await loadConfig();
|
|
6
7
|
const api = trackClientFromConfig(config);
|
|
7
|
-
const [
|
|
8
|
-
console.log("
|
|
8
|
+
const [codingContext, challenge] = await getCommonChallengeContext(config, api);
|
|
9
|
+
console.log("A copy of your existing code will be archived in this directory, and the original challenge code will be re-downloaded.");
|
|
9
10
|
const shouldContinue = dntShim.confirm("Are you sure you want to reset this challenge?");
|
|
10
11
|
if (!shouldContinue) {
|
|
11
12
|
return;
|
|
12
13
|
}
|
|
14
|
+
// Update the remote files without modifying the local copy
|
|
15
|
+
await resetRemoteFiles(api, codingContext, challenge);
|
|
16
|
+
// Once the remote update succeeded,
|
|
17
|
+
// archive the local files before re-downloading the remote files following the reset.
|
|
13
18
|
const currentDir = dntShim.Deno.cwd();
|
|
14
19
|
await archiveExistingChallengeFiles(config.orgName);
|
|
15
|
-
await api.reset();
|
|
16
20
|
const newCodingContext = await api.context();
|
|
17
21
|
const showFileDiff = false;
|
|
18
22
|
const includeTarball = true;
|
|
19
23
|
await downloadChallengeFilesTo(newCodingContext, currentDir, api, showFileDiff, includeTarball);
|
|
20
24
|
}
|
|
25
|
+
async function resetRemoteFiles(api, codingContext, challenge) {
|
|
26
|
+
if (challenge.style === ChallengeStyle.Frontend) {
|
|
27
|
+
const seriesCode = codingContext.selectedFrontendTemplate?.seriesCode ??
|
|
28
|
+
// In the unlikely event that no template is selected, arbitrarily pick the first available one
|
|
29
|
+
codingContext.availableFrontendTemplates?.[0]?.seriesCode ??
|
|
30
|
+
// Extremely unlikely fallback:
|
|
31
|
+
(await api.frontendTemplates())[0].seriesCode;
|
|
32
|
+
await api.updateFrontendTemplate(seriesCode);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// For non-frontend (Algorithm/Development/Function) use the reset API
|
|
36
|
+
await api.reset();
|
|
37
|
+
}
|
|
38
|
+
}
|
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 = "4.1.0
|
|
4
|
+
export const VERSION = "4.1.0";
|
|
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) {
|