Skip to content

Commit

Permalink
Continues progress on web-enabled build
Browse files Browse the repository at this point in the history
Consolidates to node-fetch 2.6.7 as Octokit requires v2
  • Loading branch information
eamodio committed Jan 18, 2022
1 parent c18dc7b commit ae490b6
Show file tree
Hide file tree
Showing 15 changed files with 1,157 additions and 301 deletions.
27 changes: 27 additions & 0 deletions .vscode/launch.json
Expand Up @@ -72,6 +72,33 @@
"sourceMaps": true,
"trace": true
},
{
"name": "Watch & Run (web)",
"type": "pwa-extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--disable-extension=eamodio.gitlens-insiders",
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionDevelopmentKind=web"
],
"cwd": "${workspaceFolder}",
"debugWebWorkerHost": true,
"rendererDebugOptions": {
"sourceMaps": true,
"webRoot": "${workspaceFolder}/src"
},
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}",
"presentation": {
"group": "1_watch",
"order": 1
},
"skipFiles": ["<node_internals>/**", "**/node_modules/**", "**/resources/app/out/vs/**"],
"smartStep": true,
"sourceMaps": true,
"trace": true
},
{
"name": "Watch & Run (sandboxed)",
"type": "pwa-extensionHost",
Expand Down
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Expand Up @@ -37,6 +37,35 @@
},
"isBackground": true,
"problemMatcher": ["$ts-checker-webpack-watch", "$ts-checker-eslint-webpack-watch"]
},
{
"label": "Run (vscode.dev)",
"group": "test",
"dependsOn": ["npm: web:serve", "npm: web:tunnel"],
"dependsOrder": "parallel",
"problemMatcher": []
},
{
"type": "npm",
"script": "web:serve",
"group": "test",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "web",
"reveal": "never"
}
},
{
"type": "npm",
"script": "web:tunnel",
"group": "test",
"isBackground": true,
"problemMatcher": [],
"presentation": {
"group": "web",
"reveal": "always"
}
}
]
}
1 change: 1 addition & 0 deletions .vscodeignore
Expand Up @@ -2,6 +2,7 @@
.vscode/**
.vscode-clean/**
.vscode-test/**
.vscode-test-web/**
.yarn/**
dist/webviews/*.css
emoji/**
Expand Down
24 changes: 14 additions & 10 deletions package.json
Expand Up @@ -10135,21 +10135,24 @@
"watch": "webpack --watch --mode development",
"watch:extension": "webpack --watch --mode development --config-name extension",
"watch:webviews": "webpack --watch --mode development --config-name webviews",
"web": "vscode-test-web --extensionDevelopmentPath=. --folder-uri=vscode-vfs://github/gitkraken/vscode-gitlens",
"web:serve": "npx serve --cors -l 5000",
"web:tunnel": "npx localtunnel -p 5000",
"update-dts": "pushd \"src/@types\" && npx vscode-dts dev && popd",
"update-dts:master": "pushd \"src/@types\" && npx vscode-dts master && popd",
"update-emoji": "node ./scripts/generateEmojiShortcodeMap.js",
"update-licenses": "node ./scripts/generateLicenses.mjs",
"vscode:prepublish": "yarn run bundle"
},
"dependencies": {
"@octokit/graphql": "4.8.0",
"@octokit/core": "3.5.1",
"@vscode/codicons": "0.0.27",
"ansi-regex": "6.0.1",
"chroma-js": "2.1.2",
"iconv-lite": "0.6.3",
"lodash-es": "4.17.21",
"md5.js": "1.3.5",
"node-fetch": "3.0.0",
"node-fetch": "2.6.7",
"path-browserify": "1.0.1",
"sortablejs": "1.14.0"
},
Expand All @@ -10160,43 +10163,44 @@
"@types/node": "14.17.4",
"@types/sortablejs": "1.10.7",
"@types/vscode": "1.63.1",
"@typescript-eslint/eslint-plugin": "5.9.1",
"@typescript-eslint/parser": "5.9.1",
"@typescript-eslint/eslint-plugin": "5.10.0",
"@typescript-eslint/parser": "5.10.0",
"@vscode/test-web": "0.0.16",
"circular-dependency-plugin": "5.2.2",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "10.2.0",
"csp-html-webpack-plugin": "5.1.0",
"css-loader": "6.5.1",
"esbuild": "0.14.11",
"esbuild-loader": "2.18.0",
"eslint": "8.6.0",
"eslint": "8.7.0",
"eslint-cli": "1.1.1",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.5.0",
"eslint-plugin-anti-trojan-source": "1.1.0",
"eslint-plugin-import": "2.25.4",
"fork-ts-checker-webpack-plugin": "6.5.0",
"html-loader": "3.0.1",
"html-loader": "3.1.0",
"html-webpack-plugin": "5.5.0",
"image-minimizer-webpack-plugin": "3.2.1",
"imagemin": "8.0.1",
"imagemin-webp": "7.0.0",
"json5": "2.2.0",
"license-checker-rseidelsohn": "2.2.0",
"mini-css-extract-plugin": "2.4.6",
"mini-css-extract-plugin": "2.5.2",
"prettier": "2.5.1",
"sass": "1.47.0",
"sass": "1.48.0",
"sass-loader": "12.4.0",
"terser-webpack-plugin": "5.3.0",
"ts-loader": "9.2.6",
"typescript": "4.5.4",
"vsce": "2.6.3",
"webpack": "5.65.0",
"webpack": "5.66.0",
"webpack-bundle-analyzer": "4.5.0",
"webpack-cli": "4.9.1"
},
"resolutions": {
"node-fetch": "2.6.1",
"node-fetch": "2.6.7",
"semver-regex": "3.1.3",
"trim-newlines": "4.0.2"
}
Expand Down
201 changes: 201 additions & 0 deletions src/@types/node-fetch.d.ts
@@ -0,0 +1,201 @@
// Type definitions for node-fetch 2.5
// Project: https://github.com/bitinn/node-fetch
// Definitions by: Torsten Werner <https://github.com/torstenwerner>
// Niklas Lindgren <https://github.com/nikcorg>
// Vinay Bedre <https://github.com/vinaybedre>
// Antonio Román <https://github.com/kyranet>
// Andrew Leedham <https://github.com/AndrewLeedham>
// Jason Li <https://github.com/JasonLi914>
// Steve Faulkner <https://github.com/southpolesteve>
// ExE Boss <https://github.com/ExE-Boss>
// Alex Savin <https://github.com/alexandrusavin>
// Alexis Tyler <https://github.com/OmgImAlexis>
// Jakub Kisielewski <https://github.com/kbkk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

declare module 'node-fetch' {
import type { Agent } from 'http';
import type { URLSearchParams, URL } from 'url';

export class Request extends Body {
constructor(input: RequestInfo, init?: RequestInit);
clone(): Request;
context: RequestContext;
headers: Headers;
method: string;
redirect: RequestRedirect;
referrer: string;
url: string;

// node-fetch extensions to the whatwg/fetch spec
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined;
compress: boolean;
counter: number;
follow: number;
hostname: string;
port?: number | undefined;
protocol: string;
size: number;
timeout: number;
}

export interface RequestInit {
// whatwg/fetch standard options
body?: BodyInit | undefined;
headers?: HeadersInit | undefined;
method?: string | undefined;
redirect?: RequestRedirect | undefined;

// node-fetch extensions
agent?: Agent | ((parsedUrl: URL) => Agent) | undefined; // =null http.Agent instance, allows custom proxy, certificate etc.
compress?: boolean | undefined; // =true support gzip/deflate content encoding. false to disable
follow?: number | undefined; // =20 maximum redirect count. 0 to not follow redirect
size?: number | undefined; // =0 maximum response body size in bytes. 0 to disable
timeout?: number | undefined; // =0 req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)

// node-fetch does not support mode, cache or credentials options
}

export type RequestContext =
| 'audio'
| 'beacon'
| 'cspreport'
| 'download'
| 'embed'
| 'eventsource'
| 'favicon'
| 'fetch'
| 'font'
| 'form'
| 'frame'
| 'hyperlink'
| 'iframe'
| 'image'
| 'imageset'
| 'import'
| 'internal'
| 'location'
| 'manifest'
| 'object'
| 'ping'
| 'plugin'
| 'prefetch'
| 'script'
| 'serviceworker'
| 'sharedworker'
| 'style'
| 'subresource'
| 'track'
| 'video'
| 'worker'
| 'xmlhttprequest'
| 'xslt';
export type RequestMode = 'cors' | 'no-cors' | 'same-origin';
export type RequestRedirect = 'error' | 'follow' | 'manual';
export type RequestCredentials = 'omit' | 'include' | 'same-origin';

export type RequestCache = 'default' | 'force-cache' | 'no-cache' | 'no-store' | 'only-if-cached' | 'reload';

export class Headers implements Iterable<[string, string]> {
constructor(init?: HeadersInit);
forEach(callback: (value: string, name: string) => void): void;
append(name: string, value: string): void;
delete(name: string): void;
get(name: string): string | null;
has(name: string): boolean;
raw(): { [k: string]: string[] };
set(name: string, value: string): void;

// Iterable methods
entries(): IterableIterator<[string, string]>;
keys(): IterableIterator<string>;
values(): IterableIterator<string>;
[Symbol.iterator](): Iterator<[string, string]>;
}

type BlobPart = ArrayBuffer | ArrayBufferView | Blob | string;

interface BlobOptions {
type?: string | undefined;
endings?: 'transparent' | 'native' | undefined;
}

export class Blob {
constructor(blobParts?: BlobPart[], options?: BlobOptions);
readonly type: string;
readonly size: number;
slice(start?: number, end?: number): Blob;
text(): Promise<string>;
}

export class Body {
constructor(body?: any, opts?: { size?: number | undefined; timeout?: number | undefined });
arrayBuffer(): Promise<ArrayBuffer>;
blob(): Promise<Blob>;
body: NodeJS.ReadableStream;
bodyUsed: boolean;
buffer(): Promise<Buffer>;
json(): Promise<any>;
size: number;
text(): Promise<string>;
textConverted(): Promise<string>;
timeout: number;
}

interface SystemError extends Error {
code?: string | undefined;
}

export class FetchError extends Error {
name: 'FetchError';
constructor(message: string, type: string, systemError?: SystemError);
type: string;
code?: string | undefined;
errno?: string | undefined;
}

export class Response extends Body {
constructor(body?: BodyInit, init?: ResponseInit);
static error(): Response;
static redirect(url: string, status: number): Response;
clone(): Response;
headers: Headers;
ok: boolean;
redirected: boolean;
status: number;
statusText: string;
type: ResponseType;
url: string;
}

export type ResponseType = 'basic' | 'cors' | 'default' | 'error' | 'opaque' | 'opaqueredirect';

export interface ResponseInit {
headers?: HeadersInit | undefined;
size?: number | undefined;
status?: number | undefined;
statusText?: string | undefined;
timeout?: number | undefined;
url?: string | undefined;
}

interface URLLike {
href: string;
}

export type HeadersInit = Headers | string[][] | { [key: string]: string };
// HeaderInit is exported to support backwards compatibility. See PR #34382
export type HeaderInit = HeadersInit;
export type BodyInit = ArrayBuffer | ArrayBufferView | NodeJS.ReadableStream | string | URLSearchParams;
export type RequestInfo = string | URLLike | Request;

declare function fetch(url: RequestInfo, init?: RequestInit): Promise<Response>;

declare namespace fetch {
function isRedirect(code: number): boolean;
}

export default fetch;
}
2 changes: 1 addition & 1 deletion src/constants.ts
Expand Up @@ -97,7 +97,7 @@ export const enum DocumentSchemes {
Output = 'output',
PRs = 'pr',
Vsls = 'vsls',
VirtualFS = 'vscode-vfs',
Virtual = 'vscode-vfs',
}

export function getEditorIfActive(document: TextDocument): TextEditor | undefined {
Expand Down

0 comments on commit ae490b6

Please sign in to comment.