-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Divide the package manager into separate components (#2188)
* Feature tests running with refactored package manager * Refactoring packages-1 * Test for the downloader running using the mock server * Using network settings * Changing the package path * Dividing packages.ts into separate components * use filter async * Use tmpfile interface * Check for the event stream * Using FilePathResolver * Remove using * Testing for normal and fallback case working * Resolve the paths * Remove failing case * package installer test-1 * Add package installer test * Create tmp asset * Package Downloader test refactored * Rename files * resolve compile issues * Clean up installer * Clean up the tests * Rename packages * Package installer test * PR feedback * Package Filter test * Remove yauzl.d.ts * Filter test * Added test for invalid zip file * method for getting the request options * remove imports * please resolve the path * remove latest in settings * Package Manager test executing * Use free port in package manager test * Package Manager (using a https server running) * using http mock server * Downloader test running using free port
- Loading branch information
Showing
45 changed files
with
1,929 additions
and
666 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import * as tmp from 'tmp'; | ||
import { rimraf } from 'async-file'; | ||
import { NestedError } from './NestedError'; | ||
|
||
export async function CreateTmpFile(): Promise<TmpAsset> { | ||
const tmpFile = await new Promise<tmp.SynchrounousResult>((resolve, reject) => { | ||
tmp.file({ prefix: 'package-' }, (err, path, fd, cleanupCallback) => { | ||
if (err) { | ||
return reject(new NestedError('Error from tmp.file', err)); | ||
} | ||
if (fd == 0) { | ||
return reject(new NestedError("Temporary package file unavailable")); | ||
} | ||
|
||
resolve(<tmp.SynchrounousResult>{ name: path, fd: fd, removeCallback: cleanupCallback }); | ||
}); | ||
}); | ||
|
||
return { | ||
fd: tmpFile.fd, | ||
name: tmpFile.name, | ||
dispose: tmpFile.removeCallback | ||
}; | ||
} | ||
|
||
export async function CreateTmpDir(unsafeCleanup: boolean): Promise<TmpAsset> { | ||
const tmpDir = await new Promise<tmp.SynchrounousResult>((resolve, reject) => { | ||
tmp.dir({ unsafeCleanup }, (err, path, cleanupCallback) => { | ||
if (err) { | ||
return reject(new NestedError('Error from tmp.dir', err)); | ||
} | ||
|
||
resolve(<tmp.SynchrounousResult>{ name: path, removeCallback: cleanupCallback }); | ||
}); | ||
}); | ||
|
||
return { | ||
fd: tmpDir.fd, | ||
name: tmpDir.name, | ||
dispose: () => { | ||
if (unsafeCleanup) { | ||
rimraf(tmpDir.name);//to delete directories that have folders inside them | ||
} | ||
else { | ||
tmpDir.removeCallback(); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
export interface TmpAsset { | ||
fd: number; | ||
name: string; | ||
dispose: () => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
export class NestedError extends Error { | ||
constructor(public message: string, public err: Error = null) { | ||
super(message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { vscode } from "./vscodeAdapter"; | ||
|
||
export default class NetworkSettings { | ||
constructor(public readonly proxy: string, public readonly strictSSL: boolean) { | ||
} | ||
} | ||
|
||
export interface NetworkSettingsProvider { | ||
(): NetworkSettings; | ||
} | ||
|
||
export function vscodeNetworkSettingsProvider(vscode: vscode): NetworkSettingsProvider { | ||
return () => { | ||
const config = vscode.workspace.getConfiguration(); | ||
const proxy = config.get<string>('http.proxy'); | ||
const strictSSL = config.get('http.proxyStrictSSL', true); | ||
return new NetworkSettings(proxy, strictSSL); | ||
}; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.