Skip to content

Commit

Permalink
cleaning code from contributing. (#1980)
Browse files Browse the repository at this point in the history
cleaning code from contributing. (#1980)
  • Loading branch information
vidorteg committed Jan 30, 2024
1 parent 69f9bd2 commit 6784abb
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 83 deletions.
26 changes: 0 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ Contributions are always welcome! We only ask that you open an issue first so we
## Development setup
* Clone this repo
* Run `npm install` in '/vscode-edge-devtools'
* Download and Extract Edge source files
* run `npm run download-edge`
* If this step fails, see [Legacy Source File Setup](#legacy-source-file-setup)
* See [Building with different Edge versions](#building-with-different-edge-versions) to target other versions of Edge
* The files will be saved at `\vscode-edge-debug\out\edge`
* Run `npm run build` or `npm run watch` in '/vscode-edge-devtools'
* Open the directory in VS Code
* Select `Launch Extension` debug configuration
Expand All @@ -32,27 +27,6 @@ Here are a list of recommended VS Code extensions to use when developing for vsc
* [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker)
* [TSLint](https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin)

## Building with different Edge versions
* Navigate to the root extension directory
* Run `node scripts/downloadAndExtractEdge [VERSION_NUMBER]` where `[VERSION_NUMBER]` is a version of Edge
* The current set of accepted `[VERSION_NUMBER]` values is 83, 84 and 85. Other numbers will target the currently supported version.
* To target other versions that this script does not support, see [Legacy Source File Setup](#legacy-source-file-setup).
* This replaces the `npm run download-edge` script in the setup instructions, follow the rest of the instructions to complete setup.

## Legacy Source File Setup
Use this method if the automated methods fail or if the desired version is not supported by the download script.
* Download a copy of the Microsoft Edge build from [https://thirdpartysource.microsoft.com](https://thirdpartysource.microsoft.com), current extension version builds from version 87.0.668.0.
* Note: Download the 'Microsoft Edge DevTools' zip if available in the desired version and platform - it will be much faster.
* Extract the necessary files from the zip
* On an administrator prompt execute the following commands (assuming your drive is located at C:\)
* **Windows**: `mkdir [PATH_TO_EXTENSION]\vscode-edge-devtools\out\edge\src\out\Release\gen\devtools&&mkdir [PATH_TO_EXTENSION]\out\edge\src\third_party\devtools-frontend\src\front_end`
* **Mac/Linux**: `mkdir -p [PATH_TO_EXTENSION]/vscode-edge-devtools/out/edge/src/out/Release/gen/devtools&&mkdir -p [PATH_TO_EXTENSION]/out/edge/src/third_party/devtools-frontend/src/front_end`
* **Open** the zip file and (inside the zip file) navigate to:
* `[COMPRESSED_FILE]\src\third_party\devtools-frontend\src\front_end`
* copy the contents of the "front_end" folder and paste them into `[PATH_TO_EXTENSION]/vscode-edge-devtools/out/edge/src/third_party/devtools-frontend/src/front_end`
* **Open** the zip file and (inside the zip file) navigate to:
* `[COMPRESSED_FILE]\src\out\Release\gen\devtools`
* copy the contents of the "devtools" folder and paste them into `[PATH_TO_EXTENSION]/vscode-edge-devtools/out/edge/src/out/Release/gen/devtools`

## Testing
* There are a set of jest tests which can be run with `npm run test`.
Expand Down
57 changes: 0 additions & 57 deletions test/helpers/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import fs from "fs";
import path from "path";
import { ExtensionContext } from "vscode";
import TelemetryReporter from "vscode-extension-telemetry";

Expand Down Expand Up @@ -214,58 +212,3 @@ export function getFirstCallback(mock: jest.Mock, callbackArgIndex: number = 0):
{ callback: Function, thisObj: object } {
return { callback: mock.mock.calls[0][callbackArgIndex], thisObj: mock.mock.instances[0] };
}

/**
* Returns the contents of the specified file, if the file is not found returns null
* @param uri The uri relative to the 'gen' folder.
*/
export function getTextFromFile(uri: string) {
// Grabbing the vscode-edge-devtools root directory path
const dirName = removeLastTwoDirectories(__dirname);
const sourceFilesPath = dirName + '/out/edge/src';

const toolsGenDir =
`${sourceFilesPath}/out/Release/gen/devtools/`;
const filePath = path.normalize(`${toolsGenDir}${uri}`);
if (fs.existsSync(filePath)) {
return fs.readFileSync(filePath, "utf8");
}

return null;
}

/**
* This helper test function grabs the source code, applies the given patch, checks to see if the patch is applied, and checks for expected and unexpected strings.
* @param filePath Path to the source file (e.g. elements/elements.js)
* @param patchFunction The patch function that replaces source code
* @param expectedStrings An array of expected strings after running the patchFunction
* @param unexpectedStrings An array of non-expected strings after running the patchFunction
*/
export async function testPatch(filePath: string, patch: (content:string)=>string|null, expectedStrings?: string[], unexpectedStrings?: string[]) {
const fileContents = getTextFromFile(filePath);
if (!fileContents) {
throw new Error(`Could not find file: ${filePath}`);
}

const result = patch(fileContents);
expect(result).not.toEqual(null);
if (expectedStrings) {
for (const expectedString of expectedStrings) {
expect(result).toEqual(expect.stringContaining(expectedString));
}
}
if (unexpectedStrings) {
for (const unexpectedString of unexpectedStrings) {
expect(result).not.toEqual(expect.stringContaining(unexpectedString));
}
}
}

/**
* @param filepath
*/
function removeLastTwoDirectories(filepath: string) {
const arr = filepath.split(path.sep);
arr.splice(-2);
return arr.join(path.sep);
}

0 comments on commit 6784abb

Please sign in to comment.