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 type { WriteStream } from "fs-extra";
|
||||||
import { constants, ensureDir, unlink } from "fs-extra";
|
import { constants, ensureDir, unlink } from "fs-extra";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import type * as FetchModule from "node-fetch";
|
import type * as FetchModule from "@k8slens/node-fetch";
|
||||||
import { promisify } from "util";
|
import { promisify } from "util";
|
||||||
import { pipeline as _pipeline, Transform, Writable } from "stream";
|
import { pipeline as _pipeline, Transform, Writable } from "stream";
|
||||||
import type { SingleBar } from "cli-progress";
|
import type { SingleBar } from "cli-progress";
|
||||||
|
|||||||
@ -47,11 +47,9 @@
|
|||||||
"author": "OpenLens Authors <info@k8slens.dev>",
|
"author": "OpenLens Authors <info@k8slens.dev>",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "env NODE_ENV=production yarn run webpack --config webpack/library-bundle.ts",
|
"build": "env NODE_ENV=production yarn run webpack --config webpack/library-bundle.ts",
|
||||||
"clean": "rm -rf dist webpack/build/ static/build",
|
"clean": "rm -rf dist static/build",
|
||||||
"compile:node-fetch": "yarn run webpack --config webpack/node-fetch.ts",
|
|
||||||
"prepare:dev": "env NODE_ENV=development yarn run webpack --config webpack/library-bundle.ts --progress",
|
"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",
|
"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:unit": "jest --testPathIgnorePatterns integration",
|
||||||
"test:watch": "func() { jest ${1} --watch --testPathIgnorePatterns integration; }; func",
|
"test:watch": "func() { jest ${1} --watch --testPathIgnorePatterns integration; }; func",
|
||||||
"lint": "PROD=true yarn run eslint --ext js,ts,tsx --max-warnings=0 .",
|
"lint": "PROD=true yarn run eslint --ext js,ts,tsx --max-warnings=0 .",
|
||||||
@ -105,13 +103,11 @@
|
|||||||
"^build"
|
"^build"
|
||||||
],
|
],
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{workspaceRoot}/build/webpack/",
|
|
||||||
"{workspaceRoot}/static/build/"
|
"{workspaceRoot}/static/build/"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dev": {
|
"dev": {
|
||||||
"outputs": [
|
"outputs": [
|
||||||
"{workspaceRoot}/build/webpack/",
|
|
||||||
"{workspaceRoot}/static/build/"
|
"{workspaceRoot}/static/build/"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@ -166,7 +162,7 @@
|
|||||||
"mobx-utils": "^6.0.4",
|
"mobx-utils": "^6.0.4",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"moment-timezone": "^0.5.40",
|
"moment-timezone": "^0.5.40",
|
||||||
"node-fetch": "^3.3.0",
|
"@k8slens/node-fetch": "^6.4.0-alpha.4",
|
||||||
"node-pty": "0.10.1",
|
"node-pty": "0.10.1",
|
||||||
"npm": "^8.19.3",
|
"npm": "^8.19.3",
|
||||||
"p-limit": "^3.1.0",
|
"p-limit": "^3.1.0",
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
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 type { AsyncResult } from "../utils/async-result";
|
||||||
import fetchInjectable from "./fetch.injectable";
|
import fetchInjectable from "./fetch.injectable";
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import type { AsyncResult } from "../../utils/async-result";
|
import type { AsyncResult } from "../../utils/async-result";
|
||||||
import type { Fetch } from "../fetch.injectable";
|
import type { Fetch } from "../fetch.injectable";
|
||||||
import type { RequestInit, Response } from "node-fetch";
|
import type { RequestInit, Response } from "@k8slens/node-fetch";
|
||||||
|
|
||||||
export interface DownloadJsonOptions {
|
export interface DownloadJsonOptions {
|
||||||
signal?: AbortSignal | null | undefined;
|
signal?: AbortSignal | null | undefined;
|
||||||
|
|||||||
@ -3,9 +3,7 @@
|
|||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type * as FetchModule from "node-fetch";
|
import * as NodeFetch from "@k8slens/node-fetch";
|
||||||
|
|
||||||
const { NodeFetch } = require("../../../build/webpack/node-fetch.bundle") as { NodeFetch: typeof FetchModule };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: while using this module can cause side effects, this specific injectable is not marked as
|
* 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.
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
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";
|
import nodeFetchModuleInjectable from "./fetch-module.injectable";
|
||||||
|
|
||||||
export type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
export type Fetch = (url: string, init?: RequestInit) => Promise<Response>;
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { Agent } from "https";
|
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 lensProxyPortInjectable from "../../main/lens-proxy/lens-proxy-port.injectable";
|
||||||
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
import lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||||
import nodeFetchModuleInjectable from "./fetch-module.injectable";
|
import nodeFetchModuleInjectable from "./fetch-module.injectable";
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { Agent } from "https";
|
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 lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||||
import fetchInjectable from "../fetch/fetch.injectable";
|
import fetchInjectable from "../fetch/fetch.injectable";
|
||||||
import loggerInjectable from "../logger.injectable";
|
import loggerInjectable from "../logger.injectable";
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import type { AgentOptions } from "https";
|
import type { AgentOptions } from "https";
|
||||||
import { Agent } 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 loggerInjectable from "../logger.injectable";
|
||||||
import isDevelopmentInjectable from "../vars/is-development.injectable";
|
import isDevelopmentInjectable from "../vars/is-development.injectable";
|
||||||
import createKubeJsonApiInjectable from "./create-kube-json-api.injectable";
|
import createKubeJsonApiInjectable from "./create-kube-json-api.injectable";
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import { Agent } from "https";
|
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 lensProxyCertificateInjectable from "../certificate/lens-proxy-certificate.injectable";
|
||||||
import fetchInjectable from "../fetch/fetch.injectable";
|
import fetchInjectable from "../fetch/fetch.injectable";
|
||||||
import loggerInjectable from "../logger.injectable";
|
import loggerInjectable from "../logger.injectable";
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
import { Agent as HttpAgent } from "http";
|
import { Agent as HttpAgent } from "http";
|
||||||
import { Agent as HttpsAgent } from "https";
|
import { Agent as HttpsAgent } from "https";
|
||||||
import { merge } from "lodash";
|
import { merge } from "lodash";
|
||||||
import type { Response, RequestInit } from "node-fetch";
|
import type { Response, RequestInit } from "@k8slens/node-fetch";
|
||||||
import { stringify } from "querystring";
|
import { stringify } from "querystring";
|
||||||
import type { Patch } from "rfc6902";
|
import type { Patch } from "rfc6902";
|
||||||
import type { PartialDeep, ValueOf } from "type-fest";
|
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 { KubeJsonApiData, KubeJsonApi } from "./kube-json-api";
|
||||||
import type { Disposer } from "../utils";
|
import type { Disposer } from "../utils";
|
||||||
import { isDefined, noop, WrappedAbortController } 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 type { Patch } from "rfc6902";
|
||||||
import assert from "assert";
|
import assert from "assert";
|
||||||
import type { PartialDeep } from "type-fest";
|
import type { PartialDeep } from "type-fest";
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import type { JsonApiData, JsonApiError } from "./json-api";
|
import type { JsonApiData, JsonApiError } from "./json-api";
|
||||||
import { JsonApi } 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";
|
import type { KubeJsonApiObjectMetadata } from "./kube-object";
|
||||||
|
|
||||||
export interface KubeJsonApiListMetadata {
|
export interface KubeJsonApiListMetadata {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ import type { IKubeWatchEvent } from "./kube-watch-event";
|
|||||||
import { ItemStore } from "../item.store";
|
import { ItemStore } from "../item.store";
|
||||||
import type { KubeApiQueryParams, KubeApi, KubeApiWatchCallback } from "./kube-api";
|
import type { KubeApiQueryParams, KubeApi, KubeApiWatchCallback } from "./kube-api";
|
||||||
import { parseKubeApi } from "./kube-api-parse";
|
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 { Patch } from "rfc6902";
|
||||||
import type { Logger } from "../logger";
|
import type { Logger } from "../logger";
|
||||||
import assert from "assert";
|
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 { JsonApiConfig } from "../../common/k8s-api/json-api";
|
||||||
import type { KubeJsonApi as InternalKubeJsonApi } from "../../common/k8s-api/kube-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 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";
|
import createKubeJsonApiForClusterInjectable from "../../common/k8s-api/create-kube-json-api-for-cluster.injectable";
|
||||||
|
|
||||||
export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
|
export const apiManager = asLegacyGlobalForExtensionApi(apiManagerInjectable);
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
* 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";
|
import { PassThrough } from "stream";
|
||||||
|
|
||||||
export const createMockResponseFromString = (url: string, data: string, statusCode = 200) => {
|
export const createMockResponseFromString = (url: string, data: string, statusCode = 200) => {
|
||||||
|
|||||||
@ -65,7 +65,6 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
|
|||||||
},
|
},
|
||||||
externals: [
|
externals: [
|
||||||
{
|
{
|
||||||
"node-fetch": "commonjs node-fetch",
|
|
||||||
"win-ca": "commonjs win-ca",
|
"win-ca": "commonjs win-ca",
|
||||||
},
|
},
|
||||||
...additionalExternals,
|
...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";
|
import path from "path";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
entry: "./node_modules/node-fetch/src/index.js",
|
entry: "./src/index.ts",
|
||||||
output: {
|
output: {
|
||||||
path: path.resolve(__dirname, "..", "build", "webpack"),
|
path: path.resolve(__dirname, "dist"),
|
||||||
filename: "node-fetch.bundle.js",
|
filename: "index.js",
|
||||||
library: {
|
library: {
|
||||||
name: "NodeFetch",
|
name: "NodeFetch",
|
||||||
type: "commonjs",
|
type: "commonjs",
|
||||||
@ -25,7 +25,22 @@ export default {
|
|||||||
externalsPresets: {
|
externalsPresets: {
|
||||||
node: true,
|
node: true,
|
||||||
},
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.(ts|tsx)$/,
|
||||||
|
loader: "ts-loader",
|
||||||
|
options: {
|
||||||
|
compilerOptions: {
|
||||||
|
declaration: true,
|
||||||
|
sourceMap: false,
|
||||||
|
outDir: path.resolve("./dist/"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
resolve: {
|
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