From 2d9855418fbac2accb4eb52d6699332fb1464755 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Wed, 4 Dec 2024 20:35:08 -0500 Subject: [PATCH] handle exported interfaces and CJS artifacts --- src/azure_auth_test.ts | 5 ++++- src/config_test.ts | 5 ++++- src/gcp_auth_test.ts | 5 ++++- src/index.ts | 2 +- src/package_test.ts | 2 ++ 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/azure_auth_test.ts b/src/azure_auth_test.ts index 48dc34b241..747c2bf8ec 100644 --- a/src/azure_auth_test.ts +++ b/src/azure_auth_test.ts @@ -1,12 +1,15 @@ import { use, expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import { join } from 'node:path'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { User, Cluster } from './config_types.js'; import { AzureAuth } from './azure_auth.js'; import { KubeConfig } from './config.js'; import { HttpMethod, RequestContext } from './index.js'; +const __dirname = dirname(fileURLToPath(import.meta.url)); + use(chaiAsPromised); describe('AzureAuth', () => { diff --git a/src/config_test.ts b/src/config_test.ts index db7afb978e..a9171d79d5 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -1,7 +1,8 @@ import { readFileSync } from 'node:fs'; import https from 'node:https'; import { Agent, RequestOptions } from 'node:https'; -import path, { join } from 'node:path'; +import path, { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; @@ -26,6 +27,8 @@ const kcInvalidContextFileName = 'testdata/empty-context-kubeconfig.yaml'; const kcInvalidClusterFileName = 'testdata/empty-cluster-kubeconfig.yaml'; const kcTlsServerNameFileName = 'testdata/tls-server-name-kubeconfig.yaml'; +const __dirname = dirname(fileURLToPath(import.meta.url)); + use(chaiAsPromised); /* tslint:disable: no-empty */ diff --git a/src/gcp_auth_test.ts b/src/gcp_auth_test.ts index ff87f3103e..ee79f0950f 100644 --- a/src/gcp_auth_test.ts +++ b/src/gcp_auth_test.ts @@ -1,5 +1,6 @@ import { expect } from 'chai'; -import { join } from 'node:path'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; import { User, Cluster } from './config_types.js'; import { GoogleCloudPlatformAuth } from './gcp_auth.js'; @@ -7,6 +8,8 @@ import { KubeConfig } from './config.js'; import { HttpMethod, RequestContext } from './gen/index.js'; import { Agent } from 'node:https'; +const __dirname = dirname(fileURLToPath(import.meta.url)); + describe('GoogleCloudPlatformAuth', () => { const testUrl1 = 'https://test-gcp.com'; var auth: GoogleCloudPlatformAuth; diff --git a/src/index.ts b/src/index.ts index 739514c401..feefcacc81 100644 --- a/src/index.ts +++ b/src/index.ts @@ -15,7 +15,7 @@ export * from './patch.js'; export * from './metrics.js'; export * from './object.js'; export * from './health.js'; -export { ConfigOptions, User, Cluster, Context } from './config_types.js'; +export { type ConfigOptions, type User, type Cluster, type Context } from './config_types.js'; // Export FetchError so that instanceof checks in user code will definitely use the same instance export { FetchError } from 'node-fetch'; diff --git a/src/package_test.ts b/src/package_test.ts index 77f3056fef..e5171d87fa 100644 --- a/src/package_test.ts +++ b/src/package_test.ts @@ -1,4 +1,6 @@ +import { createRequire } from 'node:module'; import { expect } from 'chai'; +const require = createRequire(import.meta.url); // Generic set of tests to verify the package is built and configured correctly describe('package', () => {