track-cli 3.0.0-rc
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/LICENSE +7 -0
- package/README.md +3 -0
- package/esm/_dnt.polyfills.d.ts +6 -0
- package/esm/_dnt.polyfills.js +1 -0
- package/esm/_dnt.shims.d.ts +19 -0
- package/esm/_dnt.shims.js +78 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.170.0/fmt/colors.js +473 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/_util/os.js +18 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assert.js +8 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.d.ts +4 -0
- package/esm/deps/deno.land/std@0.195.0/assert/assertion_error.js +12 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.d.ts +50 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/_common.js +545 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.d.ts +55 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/constants.js +57 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/day_of_year.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.d.ts +38 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/difference.js +93 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.d.ts +22 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/format.js +28 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.d.ts +49 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/is_leap.js +60 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.d.ts +43 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/mod.js +45 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.d.ts +21 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/parse.js +29 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/to_imf.js +44 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/datetime/week_of_year.js +38 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.d.ts +270 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/colors.js +474 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.d.ts +15 -0
- package/esm/deps/deno.land/std@0.195.0/fmt/duration.js +96 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.d.ts +35 -0
- package/esm/deps/deno.land/std@0.195.0/fs/_util.js +80 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.d.ts +51 -0
- package/esm/deps/deno.land/std@0.195.0/fs/copy.js +244 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/empty_dir.js +74 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.d.ts +27 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_dir.js +55 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.d.ts +33 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_file.js +75 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.d.ts +31 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_link.js +43 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.d.ts +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/ensure_symlink.js +68 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/eol.js +53 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.d.ts +102 -0
- package/esm/deps/deno.land/std@0.195.0/fs/exists.js +163 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.d.ts +37 -0
- package/esm/deps/deno.land/std@0.195.0/fs/expand_glob.js +216 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.d.ts +16 -0
- package/esm/deps/deno.land/std@0.195.0/fs/mod.js +17 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.d.ts +29 -0
- package/esm/deps/deno.land/std@0.195.0/fs/move.js +88 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.d.ts +40 -0
- package/esm/deps/deno.land/std@0.195.0/fs/walk.js +158 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.d.ts +39 -0
- package/esm/deps/deno.land/std@0.195.0/path/_constants.js +46 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.d.ts +26 -0
- package/esm/deps/deno.land/std@0.195.0/path/_interface.js +3 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.d.ts +11 -0
- package/esm/deps/deno.land/std@0.195.0/path/_util.js +161 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.d.ts +13 -0
- package/esm/deps/deno.land/std@0.195.0/path/common.js +36 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.d.ts +83 -0
- package/esm/deps/deno.land/std@0.195.0/path/glob.js +361 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.d.ts +9 -0
- package/esm/deps/deno.land/std@0.195.0/path/mod.js +33 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.d.ts +86 -0
- package/esm/deps/deno.land/std@0.195.0/path/posix.js +442 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.d.ts +2 -0
- package/esm/deps/deno.land/std@0.195.0/path/separator.js +5 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.d.ts +91 -0
- package/esm/deps/deno.land/std@0.195.0/path/win32.js +909 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/_utils/distance.js +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.d.ts +76 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_errors.js +154 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.d.ts +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/_utils.js +105 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.d.ts +831 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/command.js +1701 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_bash_completions_generator.js +201 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_fish_completions_generator.js +141 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.d.ts +21 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/_zsh_completions_generator.js +285 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/bash.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.d.ts +8 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/complete.js +32 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/fish.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/mod.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/completions/zsh.js +38 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.d.ts +45 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deprecated.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/_help_generator.js +323 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.d.ts +6 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/help/mod.js +34 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/mod.js +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.d.ts +41 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/type.js +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/action_list.js +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/boolean.js +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.d.ts +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/child_command.js +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/command.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/enum.js +29 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/file.js +12 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.d.ts +7 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types/string.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.d.ts +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/types.js +2 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.d.ts +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/mod.js +5 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/deno_land.js +46 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.d.ts +26 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/github.js +118 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.d.ts +14 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider/nest_land.js +55 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.d.ts +27 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/provider.js +102 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.d.ts +17 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/command/upgrade/upgrade_command.js +75 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.d.ts +60 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_errors.js +117 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.d.ts +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_utils.js +106 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.d.ts +10 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/_validate_flags.js +157 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.d.ts +24 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/deprecated.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.d.ts +33 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/flags.js +402 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/boolean.js +11 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/integer.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/number.js +9 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.d.ts +3 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types/string.js +4 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.d.ts +59 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/flags/types.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.d.ts +20 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/border.js +18 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.d.ts +78 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/cell.js +128 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.d.ts +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/deps.js +1 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.d.ts +99 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/layout.js +529 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.d.ts +49 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/row.js +74 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.d.ts +135 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/table.js +237 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.d.ts +13 -0
- package/esm/deps/deno.land/x/cliffy@v0.25.7/table/utils.js +60 -0
- package/esm/package.json +3 -0
- package/esm/src/action/add.d.ts +1 -0
- package/esm/src/action/add.js +57 -0
- package/esm/src/action/clone.d.ts +6 -0
- package/esm/src/action/clone.js +108 -0
- package/esm/src/action/lang.d.ts +1 -0
- package/esm/src/action/lang.js +40 -0
- package/esm/src/action/pull.d.ts +1 -0
- package/esm/src/action/pull.js +22 -0
- package/esm/src/action/remove.d.ts +4 -0
- package/esm/src/action/remove.js +67 -0
- package/esm/src/action/reset.d.ts +1 -0
- package/esm/src/action/reset.js +21 -0
- package/esm/src/action/run.d.ts +4 -0
- package/esm/src/action/run.js +163 -0
- package/esm/src/action/status.d.ts +1 -0
- package/esm/src/action/status.js +5 -0
- package/esm/src/main.d.ts +2 -0
- package/esm/src/main.js +96 -0
- package/esm/src/meta.d.ts +3 -0
- package/esm/src/meta.js +51 -0
- package/esm/src/orca/client.d.ts +20 -0
- package/esm/src/orca/client.js +152 -0
- package/esm/src/orca/types.d.ts +54 -0
- package/esm/src/orca/types.js +12 -0
- package/esm/src/shared/config.d.ts +24 -0
- package/esm/src/shared/config.js +24 -0
- package/esm/src/shared/errors.d.ts +82 -0
- package/esm/src/shared/errors.js +228 -0
- package/esm/src/shared/file.d.ts +30 -0
- package/esm/src/shared/file.js +110 -0
- package/esm/src/shared/mod.d.ts +40 -0
- package/esm/src/shared/mod.js +383 -0
- package/esm/src/shared/types.d.ts +12 -0
- package/esm/src/shared/types.js +1 -0
- package/esm/src/track/client.d.ts +60 -0
- package/esm/src/track/client.js +268 -0
- package/esm/src/track/types.d.ts +210 -0
- package/esm/src/track/types.js +40 -0
- package/package.json +35 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { IBorder } from "./border.js";
|
|
2
|
+
import { Direction } from "./cell.js";
|
|
3
|
+
import { IDataRow, IRow, Row } from "./row.js";
|
|
4
|
+
/** Border characters settings. */
|
|
5
|
+
export type IBorderOptions = Partial<IBorder>;
|
|
6
|
+
/** Table options. */
|
|
7
|
+
export interface ITableOptions {
|
|
8
|
+
indent?: number;
|
|
9
|
+
border?: boolean;
|
|
10
|
+
align?: Direction;
|
|
11
|
+
maxColWidth?: number | number[];
|
|
12
|
+
minColWidth?: number | number[];
|
|
13
|
+
padding?: number | number[];
|
|
14
|
+
chars?: IBorderOptions;
|
|
15
|
+
}
|
|
16
|
+
/** Table settings. */
|
|
17
|
+
export interface ITableSettings extends Required<Omit<ITableOptions, "align">> {
|
|
18
|
+
chars: IBorder;
|
|
19
|
+
align?: Direction;
|
|
20
|
+
}
|
|
21
|
+
/** Table type. */
|
|
22
|
+
export type ITable<T extends IRow = IRow> = T[] | Table<T>;
|
|
23
|
+
/** Table representation. */
|
|
24
|
+
export declare class Table<T extends IRow = IRow> extends Array<T> {
|
|
25
|
+
protected static _chars: IBorder;
|
|
26
|
+
protected options: ITableSettings;
|
|
27
|
+
private headerRow?;
|
|
28
|
+
/**
|
|
29
|
+
* Create a new table. If rows is a table, all rows and options of the table
|
|
30
|
+
* will be copied to the new table.
|
|
31
|
+
* @param rows
|
|
32
|
+
*/
|
|
33
|
+
static from<T extends IRow>(rows: ITable<T>): Table<T>;
|
|
34
|
+
/**
|
|
35
|
+
* Create a new table from an array of json objects. An object represents a
|
|
36
|
+
* row and each property a column.
|
|
37
|
+
* @param rows Array of objects.
|
|
38
|
+
*/
|
|
39
|
+
static fromJson(rows: IDataRow[]): Table;
|
|
40
|
+
/**
|
|
41
|
+
* Set global default border characters.
|
|
42
|
+
* @param chars Border options.
|
|
43
|
+
*/
|
|
44
|
+
static chars(chars: IBorderOptions): typeof Table;
|
|
45
|
+
/**
|
|
46
|
+
* Write table or rows to stdout.
|
|
47
|
+
* @param rows Table or rows.
|
|
48
|
+
*/
|
|
49
|
+
static render<T extends IRow>(rows: ITable<T>): void;
|
|
50
|
+
/**
|
|
51
|
+
* Read data from an array of json objects. An object represents a
|
|
52
|
+
* row and each property a column.
|
|
53
|
+
* @param rows Array of objects.
|
|
54
|
+
*/
|
|
55
|
+
fromJson(rows: IDataRow[]): this;
|
|
56
|
+
/**
|
|
57
|
+
* Set table header.
|
|
58
|
+
* @param header Header row or cells.
|
|
59
|
+
*/
|
|
60
|
+
header(header: IRow): this;
|
|
61
|
+
/**
|
|
62
|
+
* Set table body.
|
|
63
|
+
* @param rows Table rows.
|
|
64
|
+
*/
|
|
65
|
+
body(rows: T[]): this;
|
|
66
|
+
/** Clone table recursively with header and options. */
|
|
67
|
+
clone(): Table;
|
|
68
|
+
/** Generate table string. */
|
|
69
|
+
toString(): string;
|
|
70
|
+
/** Write table to stdout. */
|
|
71
|
+
render(): this;
|
|
72
|
+
/**
|
|
73
|
+
* Set max col with.
|
|
74
|
+
* @param width Max col width.
|
|
75
|
+
* @param override Override existing value.
|
|
76
|
+
*/
|
|
77
|
+
maxColWidth(width: number | number[], override?: boolean): this;
|
|
78
|
+
/**
|
|
79
|
+
* Set min col width.
|
|
80
|
+
* @param width Min col width.
|
|
81
|
+
* @param override Override existing value.
|
|
82
|
+
*/
|
|
83
|
+
minColWidth(width: number | number[], override?: boolean): this;
|
|
84
|
+
/**
|
|
85
|
+
* Set table indentation.
|
|
86
|
+
* @param width Indent width.
|
|
87
|
+
* @param override Override existing value.
|
|
88
|
+
*/
|
|
89
|
+
indent(width: number, override?: boolean): this;
|
|
90
|
+
/**
|
|
91
|
+
* Set cell padding.
|
|
92
|
+
* @param padding Cell padding.
|
|
93
|
+
* @param override Override existing value.
|
|
94
|
+
*/
|
|
95
|
+
padding(padding: number | number[], override?: boolean): this;
|
|
96
|
+
/**
|
|
97
|
+
* Enable/disable cell border.
|
|
98
|
+
* @param enable Enable/disable cell border.
|
|
99
|
+
* @param override Override existing value.
|
|
100
|
+
*/
|
|
101
|
+
border(enable: boolean, override?: boolean): this;
|
|
102
|
+
/**
|
|
103
|
+
* Align table content.
|
|
104
|
+
* @param direction Align direction.
|
|
105
|
+
* @param override Override existing value.
|
|
106
|
+
*/
|
|
107
|
+
align(direction: Direction, override?: boolean): this;
|
|
108
|
+
/**
|
|
109
|
+
* Set border characters.
|
|
110
|
+
* @param chars Border options.
|
|
111
|
+
*/
|
|
112
|
+
chars(chars: IBorderOptions): this;
|
|
113
|
+
/** Get table header. */
|
|
114
|
+
getHeader(): Row | undefined;
|
|
115
|
+
/** Get table body. */
|
|
116
|
+
getBody(): T[];
|
|
117
|
+
/** Get mac col widrth. */
|
|
118
|
+
getMaxColWidth(): number | number[];
|
|
119
|
+
/** Get min col width. */
|
|
120
|
+
getMinColWidth(): number | number[];
|
|
121
|
+
/** Get table indentation. */
|
|
122
|
+
getIndent(): number;
|
|
123
|
+
/** Get cell padding. */
|
|
124
|
+
getPadding(): number | number[];
|
|
125
|
+
/** Check if table has border. */
|
|
126
|
+
getBorder(): boolean;
|
|
127
|
+
/** Check if header row has border. */
|
|
128
|
+
hasHeaderBorder(): boolean;
|
|
129
|
+
/** Check if table bordy has border. */
|
|
130
|
+
hasBodyBorder(): boolean;
|
|
131
|
+
/** Check if table header or body has border. */
|
|
132
|
+
hasBorder(): boolean;
|
|
133
|
+
/** Get table alignment. */
|
|
134
|
+
getAlign(): Direction;
|
|
135
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { border } from "./border.js";
|
|
2
|
+
import { Cell } from "./cell.js";
|
|
3
|
+
import { TableLayout } from "./layout.js";
|
|
4
|
+
import { Row } from "./row.js";
|
|
5
|
+
/** Table representation. */
|
|
6
|
+
class Table extends Array {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
Object.defineProperty(this, "options", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
configurable: true,
|
|
12
|
+
writable: true,
|
|
13
|
+
value: {
|
|
14
|
+
indent: 0,
|
|
15
|
+
border: false,
|
|
16
|
+
maxColWidth: Infinity,
|
|
17
|
+
minColWidth: 0,
|
|
18
|
+
padding: 1,
|
|
19
|
+
chars: { ...Table._chars },
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(this, "headerRow", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
configurable: true,
|
|
25
|
+
writable: true,
|
|
26
|
+
value: void 0
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a new table. If rows is a table, all rows and options of the table
|
|
31
|
+
* will be copied to the new table.
|
|
32
|
+
* @param rows
|
|
33
|
+
*/
|
|
34
|
+
static from(rows) {
|
|
35
|
+
const table = new this(...rows);
|
|
36
|
+
if (rows instanceof Table) {
|
|
37
|
+
table.options = { ...rows.options };
|
|
38
|
+
table.headerRow = rows.headerRow ? Row.from(rows.headerRow) : undefined;
|
|
39
|
+
}
|
|
40
|
+
return table;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a new table from an array of json objects. An object represents a
|
|
44
|
+
* row and each property a column.
|
|
45
|
+
* @param rows Array of objects.
|
|
46
|
+
*/
|
|
47
|
+
static fromJson(rows) {
|
|
48
|
+
return new this().fromJson(rows);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Set global default border characters.
|
|
52
|
+
* @param chars Border options.
|
|
53
|
+
*/
|
|
54
|
+
static chars(chars) {
|
|
55
|
+
Object.assign(this._chars, chars);
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Write table or rows to stdout.
|
|
60
|
+
* @param rows Table or rows.
|
|
61
|
+
*/
|
|
62
|
+
static render(rows) {
|
|
63
|
+
Table.from(rows).render();
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Read data from an array of json objects. An object represents a
|
|
67
|
+
* row and each property a column.
|
|
68
|
+
* @param rows Array of objects.
|
|
69
|
+
*/
|
|
70
|
+
fromJson(rows) {
|
|
71
|
+
this.header(Object.keys(rows[0]));
|
|
72
|
+
this.body(rows.map((row) => Object.values(row)));
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Set table header.
|
|
77
|
+
* @param header Header row or cells.
|
|
78
|
+
*/
|
|
79
|
+
header(header) {
|
|
80
|
+
this.headerRow = header instanceof Row ? header : Row.from(header);
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Set table body.
|
|
85
|
+
* @param rows Table rows.
|
|
86
|
+
*/
|
|
87
|
+
body(rows) {
|
|
88
|
+
this.length = 0;
|
|
89
|
+
this.push(...rows);
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/** Clone table recursively with header and options. */
|
|
93
|
+
clone() {
|
|
94
|
+
const table = new Table(...this.map((row) => row instanceof Row ? row.clone() : Row.from(row).clone()));
|
|
95
|
+
table.options = { ...this.options };
|
|
96
|
+
table.headerRow = this.headerRow?.clone();
|
|
97
|
+
return table;
|
|
98
|
+
}
|
|
99
|
+
/** Generate table string. */
|
|
100
|
+
toString() {
|
|
101
|
+
return new TableLayout(this, this.options).toString();
|
|
102
|
+
}
|
|
103
|
+
/** Write table to stdout. */
|
|
104
|
+
render() {
|
|
105
|
+
console.log(this.toString());
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Set max col with.
|
|
110
|
+
* @param width Max col width.
|
|
111
|
+
* @param override Override existing value.
|
|
112
|
+
*/
|
|
113
|
+
maxColWidth(width, override = true) {
|
|
114
|
+
if (override || typeof this.options.maxColWidth === "undefined") {
|
|
115
|
+
this.options.maxColWidth = width;
|
|
116
|
+
}
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Set min col width.
|
|
121
|
+
* @param width Min col width.
|
|
122
|
+
* @param override Override existing value.
|
|
123
|
+
*/
|
|
124
|
+
minColWidth(width, override = true) {
|
|
125
|
+
if (override || typeof this.options.minColWidth === "undefined") {
|
|
126
|
+
this.options.minColWidth = width;
|
|
127
|
+
}
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Set table indentation.
|
|
132
|
+
* @param width Indent width.
|
|
133
|
+
* @param override Override existing value.
|
|
134
|
+
*/
|
|
135
|
+
indent(width, override = true) {
|
|
136
|
+
if (override || typeof this.options.indent === "undefined") {
|
|
137
|
+
this.options.indent = width;
|
|
138
|
+
}
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Set cell padding.
|
|
143
|
+
* @param padding Cell padding.
|
|
144
|
+
* @param override Override existing value.
|
|
145
|
+
*/
|
|
146
|
+
padding(padding, override = true) {
|
|
147
|
+
if (override || typeof this.options.padding === "undefined") {
|
|
148
|
+
this.options.padding = padding;
|
|
149
|
+
}
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Enable/disable cell border.
|
|
154
|
+
* @param enable Enable/disable cell border.
|
|
155
|
+
* @param override Override existing value.
|
|
156
|
+
*/
|
|
157
|
+
border(enable, override = true) {
|
|
158
|
+
if (override || typeof this.options.border === "undefined") {
|
|
159
|
+
this.options.border = enable;
|
|
160
|
+
}
|
|
161
|
+
return this;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Align table content.
|
|
165
|
+
* @param direction Align direction.
|
|
166
|
+
* @param override Override existing value.
|
|
167
|
+
*/
|
|
168
|
+
align(direction, override = true) {
|
|
169
|
+
if (override || typeof this.options.align === "undefined") {
|
|
170
|
+
this.options.align = direction;
|
|
171
|
+
}
|
|
172
|
+
return this;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Set border characters.
|
|
176
|
+
* @param chars Border options.
|
|
177
|
+
*/
|
|
178
|
+
chars(chars) {
|
|
179
|
+
Object.assign(this.options.chars, chars);
|
|
180
|
+
return this;
|
|
181
|
+
}
|
|
182
|
+
/** Get table header. */
|
|
183
|
+
getHeader() {
|
|
184
|
+
return this.headerRow;
|
|
185
|
+
}
|
|
186
|
+
/** Get table body. */
|
|
187
|
+
getBody() {
|
|
188
|
+
return [...this];
|
|
189
|
+
}
|
|
190
|
+
/** Get mac col widrth. */
|
|
191
|
+
getMaxColWidth() {
|
|
192
|
+
return this.options.maxColWidth;
|
|
193
|
+
}
|
|
194
|
+
/** Get min col width. */
|
|
195
|
+
getMinColWidth() {
|
|
196
|
+
return this.options.minColWidth;
|
|
197
|
+
}
|
|
198
|
+
/** Get table indentation. */
|
|
199
|
+
getIndent() {
|
|
200
|
+
return this.options.indent;
|
|
201
|
+
}
|
|
202
|
+
/** Get cell padding. */
|
|
203
|
+
getPadding() {
|
|
204
|
+
return this.options.padding;
|
|
205
|
+
}
|
|
206
|
+
/** Check if table has border. */
|
|
207
|
+
getBorder() {
|
|
208
|
+
return this.options.border === true;
|
|
209
|
+
}
|
|
210
|
+
/** Check if header row has border. */
|
|
211
|
+
hasHeaderBorder() {
|
|
212
|
+
const hasBorder = this.headerRow?.hasBorder();
|
|
213
|
+
return hasBorder === true || (this.getBorder() && hasBorder !== false);
|
|
214
|
+
}
|
|
215
|
+
/** Check if table bordy has border. */
|
|
216
|
+
hasBodyBorder() {
|
|
217
|
+
return this.getBorder() ||
|
|
218
|
+
this.some((row) => row instanceof Row
|
|
219
|
+
? row.hasBorder()
|
|
220
|
+
: row.some((cell) => cell instanceof Cell ? cell.getBorder : false));
|
|
221
|
+
}
|
|
222
|
+
/** Check if table header or body has border. */
|
|
223
|
+
hasBorder() {
|
|
224
|
+
return this.hasHeaderBorder() || this.hasBodyBorder();
|
|
225
|
+
}
|
|
226
|
+
/** Get table alignment. */
|
|
227
|
+
getAlign() {
|
|
228
|
+
return this.options.align ?? "left";
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
Object.defineProperty(Table, "_chars", {
|
|
232
|
+
enumerable: true,
|
|
233
|
+
configurable: true,
|
|
234
|
+
writable: true,
|
|
235
|
+
value: { ...border }
|
|
236
|
+
});
|
|
237
|
+
export { Table };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get next words from the beginning of [content] until all words have a length lower or equal then [length].
|
|
3
|
+
*
|
|
4
|
+
* @param length Max length of all words.
|
|
5
|
+
* @param content The text content.
|
|
6
|
+
*/
|
|
7
|
+
import { ICell } from "./cell.js";
|
|
8
|
+
export declare function consumeWords(length: number, content: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Get longest cell from given row index.
|
|
11
|
+
*/
|
|
12
|
+
export declare function longest(index: number, rows: ICell[][], maxWidth?: number): number;
|
|
13
|
+
export declare const strLength: (str: string) => number;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get next words from the beginning of [content] until all words have a length lower or equal then [length].
|
|
3
|
+
*
|
|
4
|
+
* @param length Max length of all words.
|
|
5
|
+
* @param content The text content.
|
|
6
|
+
*/
|
|
7
|
+
import { Cell } from "./cell.js";
|
|
8
|
+
import { stripColor } from "./deps.js";
|
|
9
|
+
export function consumeWords(length, content) {
|
|
10
|
+
let consumed = "";
|
|
11
|
+
const words = content.split("\n")[0]?.split(/ /g);
|
|
12
|
+
for (let i = 0; i < words.length; i++) {
|
|
13
|
+
const word = words[i];
|
|
14
|
+
// consume minimum one word
|
|
15
|
+
if (consumed) {
|
|
16
|
+
const nextLength = strLength(word);
|
|
17
|
+
const consumedLength = strLength(consumed);
|
|
18
|
+
if (consumedLength + nextLength >= length) {
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
consumed += (i > 0 ? " " : "") + word;
|
|
23
|
+
}
|
|
24
|
+
return consumed;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get longest cell from given row index.
|
|
28
|
+
*/
|
|
29
|
+
export function longest(index, rows, maxWidth) {
|
|
30
|
+
const cellLengths = rows.map((row) => {
|
|
31
|
+
const cell = row[index];
|
|
32
|
+
const cellValue = cell instanceof Cell && cell.getColSpan() > 1
|
|
33
|
+
? ""
|
|
34
|
+
: cell?.toString() || "";
|
|
35
|
+
return cellValue
|
|
36
|
+
.split("\n")
|
|
37
|
+
.map((line) => {
|
|
38
|
+
const str = typeof maxWidth === "undefined"
|
|
39
|
+
? line
|
|
40
|
+
: consumeWords(maxWidth, line);
|
|
41
|
+
return strLength(str) || 0;
|
|
42
|
+
});
|
|
43
|
+
}).flat();
|
|
44
|
+
return Math.max(...cellLengths);
|
|
45
|
+
}
|
|
46
|
+
export const strLength = (str) => {
|
|
47
|
+
str = stripColor(str);
|
|
48
|
+
let length = 0;
|
|
49
|
+
for (let i = 0; i < str.length; i++) {
|
|
50
|
+
const charCode = str.charCodeAt(i);
|
|
51
|
+
// Check for chinese characters: \u4e00 - \u9fa5
|
|
52
|
+
if (charCode >= 19968 && charCode <= 40869) {
|
|
53
|
+
length += 2;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
length += 1;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return length;
|
|
60
|
+
};
|
package/esm/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function add(filePaths: string[]): Promise<void>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { CONFIG_FILE_PATH } from "../shared/config.js";
|
|
3
|
+
import { CantReadFile, NewFilesNotAllowed } from "../shared/errors.js";
|
|
4
|
+
import { pathsToFilenameSet, toNativeStyle } from "../shared/file.js";
|
|
5
|
+
import { getCommonChallengeContext, listFileNames, printWorkingFileSet, } from "../shared/mod.js";
|
|
6
|
+
import { FileListType } from "../track/types.js";
|
|
7
|
+
import * as colors from "../../deps/deno.land/std@0.195.0/fmt/colors.js";
|
|
8
|
+
export async function add(filePaths) {
|
|
9
|
+
// console.log("add", filePaths);
|
|
10
|
+
const trackContext = await getCommonChallengeContext();
|
|
11
|
+
const { config, api, codingContext } = trackContext;
|
|
12
|
+
if (!codingContext.settings.allowNewFile) {
|
|
13
|
+
throw new NewFilesNotAllowed();
|
|
14
|
+
}
|
|
15
|
+
const requestedPaths = await pathsToFilenameSet(filePaths, {
|
|
16
|
+
recursive: true,
|
|
17
|
+
allowNonExistent: false,
|
|
18
|
+
});
|
|
19
|
+
const existingPaths = new Set(listFileNames(codingContext, FileListType.All));
|
|
20
|
+
// Don't allow the config file to be added
|
|
21
|
+
existingPaths.add(CONFIG_FILE_PATH);
|
|
22
|
+
const pathsToAdd = Array.from(requestedPaths).filter((p) => !existingPaths.has(p));
|
|
23
|
+
const addedFiles = listFileNames(codingContext, FileListType.UserAddedFiles)
|
|
24
|
+
.concat(pathsToAdd);
|
|
25
|
+
const updatedFiles = {};
|
|
26
|
+
const decoder = new TextDecoder("utf-8");
|
|
27
|
+
for (const path of pathsToAdd) {
|
|
28
|
+
try {
|
|
29
|
+
updatedFiles[path] = decoder.decode(await dntShim.Deno.readFile(path));
|
|
30
|
+
}
|
|
31
|
+
catch (_e) {
|
|
32
|
+
throw new CantReadFile(path);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
if (pathsToAdd.length > 0) {
|
|
36
|
+
const saveFilesRequest = {
|
|
37
|
+
versionId: codingContext.challengeVersionId,
|
|
38
|
+
addedFiles,
|
|
39
|
+
updatedFiles,
|
|
40
|
+
};
|
|
41
|
+
const updatedDisplayFiles = Object.keys(updatedFiles);
|
|
42
|
+
updatedDisplayFiles.sort();
|
|
43
|
+
console.log(colors.green("Uploading:"));
|
|
44
|
+
for (const path of updatedDisplayFiles) {
|
|
45
|
+
console.log(`\t${toNativeStyle(path)}`);
|
|
46
|
+
}
|
|
47
|
+
console.log();
|
|
48
|
+
await api.saveFiles(config.applicantExamId, config.challengeResultId, saveFilesRequest);
|
|
49
|
+
const newCodingContext = await api.getChallengeCodingContext(config.applicantExamId, config.challengeResultId);
|
|
50
|
+
printWorkingFileSet(newCodingContext);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
console.log("No files to add.");
|
|
54
|
+
console.log();
|
|
55
|
+
printWorkingFileSet(codingContext);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import * as config from "../shared/config.js";
|
|
3
|
+
import { ChallengeDirectoryExists, InvalidChallengeId, LocalExamNotAllowed, OtherError, } from "../shared/errors.js";
|
|
4
|
+
import { downloadChallengeFilesTo, ensureExamInProgress, getChallengeFromExamSession, printTimeLeft, tryStartingChallenge, } from "../shared/mod.js";
|
|
5
|
+
import { TrackClient } from "../track/client.js";
|
|
6
|
+
import { exists } from "../../deps/deno.land/std@0.195.0/fs/mod.js";
|
|
7
|
+
export async function clone(url, options) {
|
|
8
|
+
// console.log(`url: ${url}`);
|
|
9
|
+
// console.log(`target_dir: ${targetDir}`);
|
|
10
|
+
// console.log(`basicAuthUser: ${basicAuthUser}`);
|
|
11
|
+
// console.log(`basicAuthPassword: ${basicAuthPassword}`);
|
|
12
|
+
const cloneData = parseUrl(url);
|
|
13
|
+
const basicAuth = options?.basicAuthUser
|
|
14
|
+
? {
|
|
15
|
+
username: options?.basicAuthUser,
|
|
16
|
+
password: options?.basicAuthPassword,
|
|
17
|
+
}
|
|
18
|
+
: undefined;
|
|
19
|
+
const authData = {
|
|
20
|
+
examToken: cloneData.examToken,
|
|
21
|
+
orgName: cloneData.orgName,
|
|
22
|
+
};
|
|
23
|
+
const api = new TrackClient(cloneData.scheme, cloneData.host, basicAuth, authData);
|
|
24
|
+
await api.authenticate();
|
|
25
|
+
const applicantExam = await api.getApplicantExamNoAuth(cloneData.examToken);
|
|
26
|
+
const webUrl = `${cloneData.scheme}://${cloneData.host}/${cloneData.orgName}/exams/${cloneData.examToken}`;
|
|
27
|
+
ensureExamInProgress(applicantExam, webUrl);
|
|
28
|
+
const examSession = await api.getExamSession(applicantExam.id);
|
|
29
|
+
// Determine challenge directory
|
|
30
|
+
const challengePosition = examSession.challengesSets
|
|
31
|
+
.flatMap((set) => set.challenges)
|
|
32
|
+
.findIndex((challenge) => challenge.id === cloneData.challengeId) +
|
|
33
|
+
1;
|
|
34
|
+
const challengeDir = options?.targetDir ||
|
|
35
|
+
`${cloneData.orgName}-challenge-${challengePosition}`;
|
|
36
|
+
const configDir = `${challengeDir}/.track`;
|
|
37
|
+
const configFile = `${configDir}/config.json`;
|
|
38
|
+
const pathExists = await exists(challengeDir);
|
|
39
|
+
if (pathExists) {
|
|
40
|
+
// オリジナルの Track CLI では空ディレクトリなら OK だったが、そのケースで特に便利にならないので、ファイル・ディレクトリが存在したら無条件でエラーに
|
|
41
|
+
throw new ChallengeDirectoryExists(challengeDir);
|
|
42
|
+
}
|
|
43
|
+
const challenge = getChallengeFromExamSession(examSession, cloneData.challengeId);
|
|
44
|
+
if (!challenge) {
|
|
45
|
+
throw new InvalidChallengeId(cloneData.challengeId);
|
|
46
|
+
}
|
|
47
|
+
if (!challenge.localExamEnabled) {
|
|
48
|
+
throw new LocalExamNotAllowed(webUrl);
|
|
49
|
+
}
|
|
50
|
+
// Find the challenge result if it exists
|
|
51
|
+
const resultOpt = getResultFromExamSession(examSession, cloneData.challengeId);
|
|
52
|
+
// Steps:
|
|
53
|
+
// - Prepare Challenge
|
|
54
|
+
// - Change language
|
|
55
|
+
// - Start Challenge
|
|
56
|
+
// - TimeLeft
|
|
57
|
+
// - Context
|
|
58
|
+
// - Presigned
|
|
59
|
+
// - Download files
|
|
60
|
+
// TODO - Print warnings about challenge time limit, having
|
|
61
|
+
// a stable internet connection, and what to do next
|
|
62
|
+
// in the challenge solving process.
|
|
63
|
+
const result = await tryStartingChallenge(challenge, api, applicantExam, resultOpt);
|
|
64
|
+
if (!result) {
|
|
65
|
+
throw new OtherError("Expected to have a challenge result after preparing and starting");
|
|
66
|
+
}
|
|
67
|
+
const timeLeft = await api.timeLeft(applicantExam.id, result.id);
|
|
68
|
+
printTimeLeft(timeLeft);
|
|
69
|
+
const codingContext = await api.getChallengeCodingContext(applicantExam.id, result.id);
|
|
70
|
+
await dntShim.Deno.mkdir(challengeDir, { recursive: true });
|
|
71
|
+
const showFileDiff = false;
|
|
72
|
+
const includeTarball = true;
|
|
73
|
+
await downloadChallengeFilesTo(codingContext, challengeDir, api, applicantExam.id, result.id, showFileDiff, includeTarball);
|
|
74
|
+
const trackConfig = {
|
|
75
|
+
scheme: cloneData.scheme,
|
|
76
|
+
host: cloneData.host,
|
|
77
|
+
orgName: cloneData.orgName,
|
|
78
|
+
basicAuth: basicAuth,
|
|
79
|
+
examToken: cloneData.examToken,
|
|
80
|
+
applicantExamId: applicantExam.id,
|
|
81
|
+
challengeId: cloneData.challengeId,
|
|
82
|
+
challengeResultId: result.id,
|
|
83
|
+
cookies: api.getCookies(),
|
|
84
|
+
programmingLanguage: result.programmingLanguage,
|
|
85
|
+
};
|
|
86
|
+
await config.save(trackConfig, { path: configFile });
|
|
87
|
+
console.log();
|
|
88
|
+
console.log(`Challenge downloaded to ${challengeDir}`);
|
|
89
|
+
console.log(`Run 'cd ${challengeDir} && track status' to begin!`);
|
|
90
|
+
}
|
|
91
|
+
const PATH_PATTERN = new RegExp("([^/]+)/exams/([^/]+)/challenges/(\\d+)");
|
|
92
|
+
function parseUrl(url) {
|
|
93
|
+
const urlObj = new URL(url);
|
|
94
|
+
const caps = PATH_PATTERN.exec(url);
|
|
95
|
+
if (!caps) {
|
|
96
|
+
throw new OtherError(`Invalid URL: ${url}`);
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
scheme: urlObj.protocol.slice(0, -1),
|
|
100
|
+
host: urlObj.host + (urlObj.port ? ":" + urlObj.port : ""),
|
|
101
|
+
orgName: caps[1],
|
|
102
|
+
examToken: caps[2],
|
|
103
|
+
challengeId: parseInt(caps[3]),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function getResultFromExamSession(examSession, challengeId) {
|
|
107
|
+
return examSession.results.find((r) => r.challengeId === challengeId);
|
|
108
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function lang(): Promise<void>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { save as saveConfig } from "../shared/config.js";
|
|
3
|
+
import { CantChooseLanguage, InvalidChallengeId } from "../shared/errors.js";
|
|
4
|
+
import { archiveExistingChallengeFiles, chooseProgrammingLanguage, downloadChallengeFilesTo, getChallengeFromExamSession, getCommonChallengeContext, } from "../shared/mod.js";
|
|
5
|
+
export async function lang() {
|
|
6
|
+
const trackContext = await getCommonChallengeContext();
|
|
7
|
+
const { config, api, codingContext, applicantExam, challengeResult, challengePosition, } = trackContext;
|
|
8
|
+
const examSession = await api.getExamSession(applicantExam.id);
|
|
9
|
+
const challenge = getChallengeFromExamSession(examSession, codingContext.challengeId) ??
|
|
10
|
+
(() => {
|
|
11
|
+
throw new InvalidChallengeId(codingContext.challengeId);
|
|
12
|
+
})();
|
|
13
|
+
if (challenge.programmingLanguages.length === 0) {
|
|
14
|
+
throw new CantChooseLanguage();
|
|
15
|
+
}
|
|
16
|
+
const availableLanguages = (await api.getProgrammingLanguages())
|
|
17
|
+
.filter((pl) => codingContext.programmingLanguages.find((n) => n === pl.value));
|
|
18
|
+
console.log("Your existing code will be archived in this directory and the original challenge code for the new language will be downloaded");
|
|
19
|
+
const shouldContinue = dntShim.confirm("Are you sure you want to continue? (y/n):");
|
|
20
|
+
if (!shouldContinue) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const desiredLanguage = await chooseProgrammingLanguage(availableLanguages);
|
|
24
|
+
if (desiredLanguage.value === codingContext.selectedLanguage) {
|
|
25
|
+
console.log("You are already using this language");
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
await api.switchChallengeLanguage(config.applicantExamId, config.challengeResultId, desiredLanguage.value);
|
|
29
|
+
const currentDir = dntShim.Deno.cwd();
|
|
30
|
+
const selectedLanguage = availableLanguages.find((pl) => pl.value === codingContext.selectedLanguage);
|
|
31
|
+
await archiveExistingChallengeFiles(config.orgName, challengePosition, { selectedLanguage, challengeDir: currentDir });
|
|
32
|
+
const newCodingContext = await api.getChallengeCodingContext(config.applicantExamId, config.challengeResultId);
|
|
33
|
+
const showFileDiff = false;
|
|
34
|
+
const includeTarball = true;
|
|
35
|
+
await downloadChallengeFilesTo(newCodingContext, currentDir, api, applicantExam.id, challengeResult.id, showFileDiff, includeTarball);
|
|
36
|
+
const updatedConfig = Object.assign({}, config, {
|
|
37
|
+
programmingLanguage: desiredLanguage.value,
|
|
38
|
+
});
|
|
39
|
+
await saveConfig(updatedConfig);
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function pull(): Promise<void>;
|