mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
move node-fetch to separate package
Signed-off-by: Jari Kolehmainen <jari.kolehmainen@gmail.com>
This commit is contained in:
parent
b2c440354c
commit
0ed06a3ac8
@ -8,7 +8,7 @@ import { open } from "fs/promises";
|
||||
import type { WriteStream } from "fs-extra";
|
||||
import { constants, ensureDir, unlink } from "fs-extra";
|
||||
import path from "path";
|
||||
import type * as FetchModule from "node-fetch";
|
||||
import type * as FetchModule from "@k8slens/node-fetch";
|
||||
import { promisify } from "util";
|
||||
import { pipeline as _pipeline, Transform, Writable } from "stream";
|
||||
import type { SingleBar } from "cli-progress";
|
||||
|
||||
@ -47,11 +47,9 @@
|
||||
"author": "OpenLens Authors <info@k8slens.dev>",
|
||||
"scripts": {
|
||||
"build": "env NODE_ENV=production yarn run webpack --config webpack/library-bundle.ts",
|
||||
"clean": "rm -rf dist webpack/build/ static/build",
|
||||
"compile:node-fetch": "yarn run webpack --config webpack/node-fetch.ts",
|
||||
"clean": "rm -rf dist static/build",
|
||||
"prepare:dev": "env NODE_ENV=development yarn run webpack --config webpack/library-bundle.ts --progress",
|
||||
"dev": "env NODE_ENV=development yarn run webpack --config webpack/library-bundle.ts --watch",
|
||||
"prepare": "yarn run compile:node-fetch",
|
||||
"test:unit": "jest --testPathIgnorePatterns integration",
|
||||
"test:watch": "func() { jest ${1} --watch --testPathIgnorePatterns integration; }; func",
|
||||
"lint": "PROD=true yarn run eslint --ext js,ts,tsx --max-warnings=0 .",
|
||||
@ -105,13 +103,11 @@
|
||||
"^build"
|
||||
],
|
||||
"outputs": [
|
||||
"{workspaceRoot}/build/webpack/",
|
||||
"{workspaceRoot}/static/build/"
|
||||
]
|
||||
},
|
||||
"dev": {
|
||||
"outputs": [
|
||||
"{workspaceRoot}/build/webpack/",
|
||||
"{workspaceRoot}/static/build/"
|
||||
]
|
||||
}
|
||||
@ -166,7 +162,7 @@
|
||||
"mobx-utils": "^6.0.4",
|
||||
"moment": "^2.29.4",
|
||||
"moment-timezone": "^0.5.40",
|
||||
"node-fetch": "^3.3.0",
|
||||
"@k8slens/node-fetch": "^6.4.0-alpha.4",
|
||||
"node-pty": "0.10.1",
|
||||
"npm": "^8.19.3",
|
||||
"p-limit": "^3.1.0",
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { RequestInit, Response } from "node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
import type { AsyncResult } from "../utils/async-result";
|
||||
import fetchInjectable from "./fetch.injectable";
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import type { AsyncResult } from "../../utils/async-result";
|
||||
import type { Fetch } from "../fetch.injectable";
|
||||
import type { RequestInit, Response } from "node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
|
||||
export interface DownloadJsonOptions {
|
||||
signal?: AbortSignal | null | undefined;
|
||||
|
||||
@ -3,9 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type * as FetchModule from "node-fetch";
|
||||
|
||||
const { NodeFetch } = require("../../../build/webpack/node-fetch.bundle") as { NodeFetch: typeof FetchModule };
|
||||
import * as NodeFetch from "@k8slens/node-fetch";
|
||||
|
||||
/**
|
||||
* NOTE: while using this module can cause side effects, this specific injectable is not marked as
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { RequestInit, Response } from "node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
import nodeFetchModuleInjectable from "./fetch-module.injectable";
|
||||
|
||||
export type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { Agent } from "https";
|
||||
import type { RequestInit, Response } from "node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
import lensProxyPortInjectable from "../../main/lens-proxy/lens-proxy-port.injectable";
|
||||
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||
import nodeFetchModuleInjectable from "./fetch-module.injectable";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { Agent } from "https";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { RequestInit } from "@k8slens/node-fetch";
|
||||
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||
import fetchInjectable from "../fetch/fetch.injectable";
|
||||
import loggerInjectable from "../logger.injectable";
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import type { AgentOptions } from "https";
|
||||
import { Agent } from "https";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { RequestInit } from "@k8slens/node-fetch";
|
||||
import loggerInjectable from "../logger.injectable";
|
||||
import isDevelopmentInjectable from "../vars/is-development.injectable";
|
||||
import createKubeJsonApiInjectable from "./create-kube-json-api.injectable";
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*/
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import { Agent } from "https";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { RequestInit } from "@k8slens/node-fetch";
|
||||
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||
import fetchInjectable from "../fetch/fetch.injectable";
|
||||
import loggerInjectable from "../logger.injectable";
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
import { Agent as HttpAgent } from "http";
|
||||
import { Agent as HttpsAgent } from "https";
|
||||
import { merge } from "lodash";
|
||||
import type { Response, RequestInit } from "node-fetch";
|
||||
import type { Response, RequestInit } from "@k8slens/node-fetch";
|
||||
import { stringify } from "querystring";
|
||||
import type { Patch } from "rfc6902";
|
||||
import type { PartialDeep, ValueOf } from "type-fest";
|
||||
|
||||
@ -15,7 +15,7 @@ import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||
import type { KubeJsonApiData, KubeJsonApi } from "./kube-json-api";
|
||||
import type { Disposer } from "../utils";
|
||||
import { isDefined, noop, WrappedAbortController } from "../utils";
|
||||
import type { RequestInit, Response } from "node-fetch";
|
||||
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||
import type { Patch } from "rfc6902";
|
||||
import assert from "assert";
|
||||
import type { PartialDeep } from "type-fest";
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
import type { JsonApiData, JsonApiError } from "./json-api";
|
||||
import { JsonApi } from "./json-api";
|
||||
import type { Response } from "node-fetch";
|
||||
import type { Response } from "@k8slens/node-fetch";
|
||||
import type { KubeJsonApiObjectMetadata } from "./kube-object";
|
||||
|
||||
export interface KubeJsonApiListMetadata {
|
||||
|
||||
@ -12,7 +12,7 @@ import type { IKubeWatchEvent } from "./kube-watch-event";
|
||||
import { ItemStore } from "../item.store";
|
||||
import type { KubeApiQueryParams, KubeApi, KubeApiWatchCallback } from "./kube-api";
|
||||
import { parseKubeApi } from "./kube-api-parse";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { RequestInit } from "@k8slens/node-fetch";
|
||||
import type { Patch } from "rfc6902";
|
||||
import type { Logger } from "../logger";
|
||||
import assert from "assert";
|
||||
|
||||
@ -30,7 +30,7 @@ import { storesAndApisCanBeCreatedInjectionToken } from "../../common/k8s-api/st
|
||||
import type { JsonApiConfig } from "../../common/k8s-api/json-api";
|
||||
import type { KubeJsonApi as InternalKubeJsonApi } from "../../common/k8s-api/kube-json-api";
|
||||
import createKubeJsonApiInjectable from "../../common/k8s-api/create-kube-json-api.injectable";
|
||||
import type { RequestInit } from "node-fetch";
|
||||
import type { RequestInit } from "@k8slens/node-fetch";
|
||||
import createKubeJsonApiForClusterInjectable from "../../common/k8s-api/create-kube-json-api-for-cluster.injectable";
|
||||
|
||||
export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { Response, Headers as NodeFetchHeaders } from "node-fetch";
|
||||
import type { Response, Headers as NodeFetchHeaders } from "@k8slens/node-fetch";
|
||||
import { PassThrough } from "stream";
|
||||
|
||||
export const createMockResponseFromString = (url: string, data: string, statusCode = 200) => {
|
||||
|
||||
@ -65,7 +65,6 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
|
||||
},
|
||||
externals: [
|
||||
{
|
||||
"node-fetch": "commonjs node-fetch",
|
||||
"win-ca": "commonjs win-ca",
|
||||
},
|
||||
...additionalExternals,
|
||||
|
||||
2
packages/node-fetch/.gitignore
vendored
Normal file
2
packages/node-fetch/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
dist/
|
||||
node_modules/
|
||||
25
packages/node-fetch/package.json
Normal file
25
packages/node-fetch/package.json
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "@k8slens/node-fetch",
|
||||
"version": "6.4.0-alpha.4",
|
||||
"description": "Node fetch for Lens",
|
||||
"license": "MIT",
|
||||
"private": false,
|
||||
"exports": {
|
||||
".": "./dist/index.js"
|
||||
},
|
||||
"types": "./dist/src/index.d.ts",
|
||||
"scripts": {
|
||||
"clean": "rm -rf dist/",
|
||||
"build": "webpack --config webpack.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": "^3.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-loader": "^9.4.2",
|
||||
"ts-node": "^10.9.1",
|
||||
"typescript": "^4.9.4",
|
||||
"webpack": "^5.75.0",
|
||||
"webpack-cli": "^5.0.1"
|
||||
}
|
||||
}
|
||||
4
packages/node-fetch/src/index.ts
Normal file
4
packages/node-fetch/src/index.ts
Normal file
@ -0,0 +1,4 @@
|
||||
import fetch from "node-fetch";
|
||||
|
||||
export * from "node-fetch";
|
||||
export default fetch;
|
||||
19
packages/node-fetch/tsconfig.json
Normal file
19
packages/node-fetch/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"extends": "../../tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"composite": true,
|
||||
"outDir": "dist/",
|
||||
"paths": {
|
||||
"*": [
|
||||
"node_modules/*",
|
||||
"types/*"
|
||||
]
|
||||
},
|
||||
},
|
||||
"include": [
|
||||
"src/**/*",
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
]
|
||||
}
|
||||
@ -5,10 +5,10 @@
|
||||
import path from "path";
|
||||
|
||||
export default {
|
||||
entry: "./node_modules/node-fetch/src/index.js",
|
||||
entry: "./src/index.ts",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "..", "build", "webpack"),
|
||||
filename: "node-fetch.bundle.js",
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "index.js",
|
||||
library: {
|
||||
name: "NodeFetch",
|
||||
type: "commonjs",
|
||||
@ -25,7 +25,22 @@ export default {
|
||||
externalsPresets: {
|
||||
node: true,
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(ts|tsx)$/,
|
||||
loader: "ts-loader",
|
||||
options: {
|
||||
compilerOptions: {
|
||||
declaration: true,
|
||||
sourceMap: false,
|
||||
outDir: path.resolve("./dist/"),
|
||||
},
|
||||
},
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [".js"],
|
||||
extensions: [".ts"],
|
||||
},
|
||||
};
|
||||
1030
packages/node-fetch/yarn.lock
Normal file
1030
packages/node-fetch/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user