download.d.ts 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { ProgressReporter } from './progress.js';
  2. import { Version } from './util';
  3. interface IFetchStableOptions {
  4. timeout: number;
  5. cachePath: string;
  6. platform: string;
  7. }
  8. interface IFetchInferredOptions extends IFetchStableOptions {
  9. extensionsDevelopmentPath?: string | string[];
  10. }
  11. export declare const fetchStableVersions: (released: boolean, timeout: number) => Promise<string[]>;
  12. export declare const fetchInsiderVersions: (released: boolean, timeout: number) => Promise<string[]>;
  13. export declare function fetchTargetInferredVersion(options: IFetchInferredOptions): Promise<Version>;
  14. /**
  15. * Adapted from https://github.com/microsoft/TypeScript/issues/29729
  16. * Since `string | 'foo'` doesn't offer auto completion
  17. */
  18. type StringLiteralUnion<T extends string> = T | (string & {});
  19. export type DownloadVersion = StringLiteralUnion<'insiders' | 'stable'>;
  20. export type DownloadPlatform = StringLiteralUnion<'darwin' | 'darwin-arm64' | 'win32-x64-archive' | 'win32-arm64-archive' | 'linux-x64' | 'linux-arm64' | 'linux-armhf'>;
  21. export interface DownloadOptions {
  22. /**
  23. * The VS Code version to download. Valid versions are:
  24. * - `'stable'`
  25. * - `'insiders'`
  26. * - `'1.32.0'`, `'1.31.1'`, etc
  27. *
  28. * Defaults to `stable`, which is latest stable version.
  29. *
  30. * *If a local copy exists at `.vscode-test/vscode-<VERSION>`, skip download.*
  31. */
  32. version: DownloadVersion;
  33. /**
  34. * The VS Code platform to download. If not specified, it defaults to the
  35. * current platform.
  36. *
  37. * Possible values are:
  38. * - `win32-x64-archive`
  39. * - `win32-arm64-archive `
  40. * - `darwin`
  41. * - `darwin-arm64`
  42. * - `linux-x64`
  43. * - `linux-arm64`
  44. * - `linux-armhf`
  45. */
  46. platform: DownloadPlatform;
  47. /**
  48. * Path where the downloaded VS Code instance is stored.
  49. * Defaults to `.vscode-test` within your working directory folder.
  50. */
  51. cachePath: string;
  52. /**
  53. * Absolute path to the extension root. Passed to `--extensionDevelopmentPath`.
  54. * Must include a `package.json` Extension Manifest.
  55. */
  56. extensionDevelopmentPath?: string | string[];
  57. /**
  58. * Progress reporter to use while VS Code is downloaded. Defaults to a
  59. * console reporter. A {@link SilentReporter} is also available, and you
  60. * may implement your own.
  61. */
  62. reporter?: ProgressReporter;
  63. /**
  64. * Whether the downloaded zip should be synchronously extracted. Should be
  65. * omitted unless you're experiencing issues installing VS Code versions.
  66. */
  67. extractSync?: boolean;
  68. /**
  69. * Number of milliseconds after which to time out if no data is received from
  70. * the remote when downloading VS Code. Note that this is an 'idle' timeout
  71. * and does not enforce the total time VS Code may take to download.
  72. */
  73. timeout?: number;
  74. }
  75. export declare const defaultCachePath: string;
  76. /**
  77. * Download and unzip a copy of VS Code.
  78. * @returns Promise of `vscodeExecutablePath`.
  79. */
  80. export declare function download(options?: Partial<DownloadOptions>): Promise<string>;
  81. /**
  82. * Download and unzip a copy of VS Code in `.vscode-test`. The paths are:
  83. * - `.vscode-test/vscode-<PLATFORM>-<VERSION>`. For example, `./vscode-test/vscode-win32-1.32.0`
  84. * - `.vscode-test/vscode-win32-insiders`.
  85. *
  86. * *If a local copy exists at `.vscode-test/vscode-<PLATFORM>-<VERSION>`, skip download.*
  87. *
  88. * @param version The version of VS Code to download such as `1.32.0`. You can also use
  89. * `'stable'` for downloading latest stable release.
  90. * `'insiders'` for downloading latest Insiders.
  91. * When unspecified, download latest stable version.
  92. *
  93. * @returns Promise of `vscodeExecutablePath`.
  94. */
  95. export declare function downloadAndUnzipVSCode(options: Partial<DownloadOptions>): Promise<string>;
  96. export declare function downloadAndUnzipVSCode(version?: DownloadVersion, platform?: DownloadPlatform, reporter?: ProgressReporter, extractSync?: boolean): Promise<string>;
  97. export {};