UNPKG

3.06 kBTypeScriptView Raw
1export type Status = 'pending' | 'loading' | 'missing' | 'failed' | 'loaded' | 'installing' | 'installed' | 'running' | 'passed';
2export type Row = [
3 icon: string,
4 version_or_alias: string,
5 rendered_status: string,
6 duration: string
7];
8/** Version */
9export declare class Version {
10 /** The precise version number, or at least the WIP version number/alias until it is resolved further. */
11 version: string;
12 /** The list of listeners we will call when updates happen. */
13 listeners: Array<Function>;
14 /** An array of aliases for this version if any were used. */
15 aliases: Array<string>;
16 /** The current status of this version, initially it is `pending`. */
17 status: Status;
18 /**
19 * The version resolution that was successfully loaded.
20 * For instance, if a nvm alias is used such as "current" which resolves to 18.18.2 which is the system Node.js version, but is not installed via nvm itself, then trying to resolve "18.18.2" will fail with [version "v18.18.2" is not yet installed] but the original "current" resolution will work.
21 */
22 loadedVersion: string | null;
23 /** Whether or not this version has been successful. */
24 success: boolean | null;
25 /** Any error that occurred against this version. */
26 error: Error | null;
27 /** The last stdout value that occurred against this version. */
28 stdout: string | null;
29 /** The last stderr value that occurred against this version. */
30 stderr: string | null;
31 /** The time the run started. */
32 started: number | null;
33 /** The time the run finished. */
34 finished: number | null;
35 /** Cache of the message. */
36 private messageCache;
37 /** Create our Version instance */
38 constructor(version: string | number, listeners?: Array<Function>);
39 /** The alias for this version if any were provided. E.g. `system` or `current` */
40 get alias(): string;
41 set alias(alias: string);
42 /** Reset the version state. */
43 reset(): this;
44 /** Notify that an update has occurred.
45 * @param {string?} status
46 * @returns {this}
47 * @private
48 */
49 update(status?: Status): Promise<this>;
50 /** Load the version, which resolves the precise version number and determines if it is available or not. */
51 load(): Promise<this>;
52 /**
53 * Install the version if it was missing.
54 * Requires the current state to be `missing`.
55 */
56 install(): Promise<this>;
57 /**
58 * Run the command against the version.
59 * Requires the current state to be `loaded`.
60 */
61 test(command: string): Promise<this>;
62 /**
63 * Converts the version properties into an array for use of displaying in a neat table.
64 * Doesn't cache as we want to refresh timers.
65 */
66 get row(): Row;
67 /**
68 * Converts the version properties a detailed message of what has occurred with this version.
69 * Caches for each status change.
70 * @property {string} message
71 * @public
72 */
73 get message(): string;
74}
75export default Version;
76//# sourceMappingURL=version.d.ts.map
\No newline at end of file