Clean up unreleased API surface

Since cli-module-auth and cli-module-actions are not yet released,
remove deprecated exports instead of keeping them. Also make httpJson
and getSecretStore internal to cli-node, duplicating the small httpJson
wrapper locally in each consuming package.

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
Made-with: Cursor
This commit is contained in:
Patrik Oldsberg
2026-03-17 16:26:49 +01:00
parent 3c6de38345
commit da8e6603a4
19 changed files with 81 additions and 102 deletions
-34
View File
@@ -4,45 +4,11 @@
```ts
import { CliModule } from '@backstage/cli-node';
import { HttpInit } from '@backstage/cli-node';
import { httpJson } from '@backstage/cli-node';
import { SecretStore } from '@backstage/cli-node';
import { StoredInstance } from '@backstage/cli-node';
// @public @deprecated (undocumented)
export function accessTokenNeedsRefresh(instance: StoredInstance): boolean;
// @public (undocumented)
const _default: CliModule;
export default _default;
// @public @deprecated (undocumented)
export function getInstanceConfig<T = unknown>(
instanceName: string,
key: string,
): Promise<T | undefined>;
// @public (undocumented)
export function getSecretStore(): Promise<SecretStore>;
// @public @deprecated (undocumented)
export function getSelectedInstance(
instanceName?: string,
): Promise<StoredInstance>;
export { HttpInit };
export { httpJson };
// @public @deprecated (undocumented)
export function refreshAccessToken(
instanceName: string,
): Promise<StoredInstance>;
export { SecretStore };
export { StoredInstance };
// @public (undocumented)
export function updateInstanceConfig(
instanceName: string,
@@ -15,7 +15,8 @@
*/
import { cli } from 'cleye';
import { CliAuth, httpJson, type CliCommandContext } from '@backstage/cli-node';
import { CliAuth, type CliCommandContext } from '@backstage/cli-node';
import { httpJson } from '../lib/http';
export default async ({ args, info }: CliCommandContext) => {
const {
+1 -13
View File
@@ -53,16 +53,4 @@ export default createCliModule({
},
});
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth} instead. */
export {
getSelectedInstance,
getInstanceConfig,
updateInstanceConfig,
type StoredInstance,
} from './lib/storage';
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth} instead. */
export { accessTokenNeedsRefresh, refreshAccessToken } from './lib/auth';
/** @public @deprecated Import from {@link @backstage/cli-node} instead. */
export { getSecretStore, type SecretStore } from './lib/secretStore';
/** @public @deprecated Import from {@link @backstage/cli-node} instead. */
export { httpJson, type HttpInit } from './lib/http';
export { updateInstanceConfig } from './lib/storage';
-2
View File
@@ -27,13 +27,11 @@ const TokenResponseSchema = z.object({
refresh_token: z.string().min(1).optional(),
});
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth} instead. */
export function accessTokenNeedsRefresh(instance: StoredInstance): boolean {
// 2 minutes before expiration
return instance.accessTokenExpiresAt <= Date.now() + 2 * 60_000;
}
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth} instead. */
export async function refreshAccessToken(
instanceName: string,
): Promise<StoredInstance> {
+23 -1
View File
@@ -14,4 +14,26 @@
* limitations under the License.
*/
export { httpJson, type HttpInit } from '@backstage/cli-node';
import { ResponseError } from '@backstage/errors';
export type HttpInit = {
headers?: Record<string, string>;
method?: string;
body?: any;
signal?: AbortSignal;
};
export async function httpJson<T>(url: string, init?: HttpInit): Promise<T> {
const res = await fetch(url, {
...init,
body: init?.body ? JSON.stringify(init.body) : undefined,
headers: {
...(init?.body ? { 'Content-Type': 'application/json' } : {}),
...init?.headers,
},
});
if (!res.ok) {
throw await ResponseError.fromResponse(res);
}
return (await res.json()) as T;
}
@@ -18,8 +18,11 @@ import fs from 'fs-extra';
import os from 'node:os';
import path from 'node:path';
export type { SecretStore } from '@backstage/cli-node';
import type { SecretStore } from '@backstage/cli-node';
type SecretStore = {
get(service: string, account: string): Promise<string | undefined>;
set(service: string, account: string, secret: string): Promise<void>;
delete(service: string, account: string): Promise<void>;
};
async function loadKeytar(): Promise<typeof import('keytar') | undefined> {
try {
@@ -86,7 +89,6 @@ class FileSecretStore implements SecretStore {
let singleton: SecretStore | undefined;
/** @public */
export async function getSecretStore(): Promise<SecretStore> {
if (!singleton) {
const keytar = await loadKeytar();
@@ -99,7 +99,6 @@ export async function getAllInstances(): Promise<{
};
}
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth} instead. */
export async function getSelectedInstance(
instanceName?: string,
): Promise<StoredInstance> {
@@ -162,7 +161,6 @@ export async function setSelectedInstance(name: string): Promise<void> {
});
}
/** @public @deprecated Use {@link @backstage/cli-node#CliAuth.getConfig} instead. */
export async function getInstanceConfig<T = unknown>(
instanceName: string,
key: string,