Skip to content

Commit

Permalink
fix: export some non-exported types (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Nov 14, 2023
1 parent 621c474 commit 31a8812
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 13 deletions.
31 changes: 26 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ import { wasmInstance } from "./src/lib/mod.ts";
import { RequestBuilder, withProgressBarFactorySymbol } from "./src/request.ts";
import { createPathRef, PathRef } from "./src/path.ts";

export type { Delay, DelayIterator } from "./src/common.ts";
export { FsFileWrapper, PathRef } from "./src/path.ts";
export type { PathSymlinkOptions, SymlinkOptions, WalkEntry } from "./src/path.ts";
export { CommandBuilder, CommandResult, KillSignal, KillSignalController } from "./src/command.ts";
export type { ExpandGlobOptions, PathSymlinkOptions, SymlinkOptions, WalkEntry, WalkOptions } from "./src/path.ts";
export { CommandBuilder, CommandChild, CommandResult, KillSignal, KillSignalController } from "./src/command.ts";
export type { CommandContext, CommandHandler, CommandPipeReader, CommandPipeWriter } from "./src/command_handler.ts";
export type { ShellPipeReader, ShellPipeWriterKind } from "./src/pipes.ts";
export type {
ConfirmOptions,
MultiSelectOption,
MultiSelectOptions,
ProgressBar,
ProgressOptions,
PromptInputMask,
PromptOptions,
SelectOptions,
} from "./src/console/mod.ts";
Expand All @@ -53,6 +56,7 @@ export type {
ExitExecuteResult,
SetEnvVarChange,
SetShellVarChange,
UnsetVarChange,
} from "./src/result.ts";

/**
Expand Down Expand Up @@ -104,6 +108,22 @@ export interface $Template {
(strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder;
}

/**
* `outdent` from the https://deno.land/x/outdent module.
* @internal
*/
type Outdent = typeof import("./src/deps.ts").outdent;
/**
* `which` from the https://deno.land/x/which module.
* @internal
*/
type Which = typeof import("./src/deps.ts").which;
/**
* `whichSync` from the https://deno.land/x/which module.
* @internal
*/
type WhichSync = typeof import("./src/deps.ts").whichSync;

export interface $BuiltInProperties<TExtras extends ExtrasObject = {}> {
/**
* Makes a request to the provided URL throwing by default if the
Expand Down Expand Up @@ -206,7 +226,7 @@ export interface $BuiltInProperties<TExtras extends ExtrasObject = {}> {
* closing line will be removed from the output,
* so that only the content in between remains.
*/
dedent: typeof outdent;
dedent: Outdent;
/**
* Determines if the provided command exists resolving to `true` if the command
* will be resolved by the shell of the current `$` or false otherwise.
Expand Down Expand Up @@ -462,9 +482,9 @@ export interface $BuiltInProperties<TExtras extends ExtrasObject = {}> {
*/
withRetries<TReturn>(opts: RetryOptions<TReturn>): Promise<TReturn>;
/** Re-export of `deno_which` for getting the path to an executable. */
which: typeof which;
which: Which;
/** Similar to `which`, but synchronously. */
whichSync: typeof whichSync;
whichSync: WhichSync;
}

function sleep(delay: Delay) {
Expand Down Expand Up @@ -509,6 +529,7 @@ function cd(path: string | URL | ImportMeta | PathRef) {
Deno.chdir(path.toString());
}

/** @internal */
type ExtrasObject = Record<string, (...args: any[]) => unknown>;

interface $State<TExtras extends ExtrasObject> {
Expand Down
1 change: 1 addition & 0 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ export class CommandResult {
/** The exit code. */
readonly code: number;

/** @internal */
constructor(code: number, stdout: BufferStdio, stderr: BufferStdio, combined: Buffer | undefined) {
this.code = code;
this.#stdout = stdout;
Expand Down
2 changes: 1 addition & 1 deletion src/console/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export type { MultiSelectOption, MultiSelectOptions } from "./multiSelect.ts";
export type { ProgressOptions } from "./progress/mod.ts";
export { isShowingProgressBars, ProgressBar } from "./progress/mod.ts";
export { maybePrompt, prompt } from "./prompt.ts";
export type { PromptOptions } from "./prompt.ts";
export type { PromptInputMask, PromptOptions } from "./prompt.ts";
export { maybeSelect, select } from "./select.ts";
export type { SelectOptions } from "./select.ts";
2 changes: 1 addition & 1 deletion src/console/progress/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class ProgressBar {

/** Does the provided action and will call `.finish()` when this is the last `.with(...)` action that runs. */
with<TResult>(action: () => TResult): TResult;
async with<TResult>(action: () => Promise<TResult>): Promise<TResult>;
with<TResult>(action: () => Promise<TResult>): Promise<TResult>;
with<TResult>(action: () => Promise<TResult> | TResult): Promise<TResult> | TResult {
this.#withCount++;
let wasAsync = false;
Expand Down
8 changes: 4 additions & 4 deletions src/console/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface PromptOptions {
* types (`false` by default).
* @default `false`
*/
mask?: InputMask | boolean;
mask?: PromptInputMask | boolean;
/**
* Whether to not clear the prompt text on selection.
* @default `false`
Expand All @@ -26,14 +26,14 @@ export interface PromptOptions {
}

/** Configuration of the prompt input mask */
export interface InputMask {
export interface PromptInputMask {
/** The character used to mask input (`*` by default) */
char?: string;
/** Whether or not to keep the last character "unmasked" (`false` by default) */
lastVisible?: boolean;
}

const defaultMask: Required<InputMask> = { char: "*", lastVisible: false };
const defaultMask: Required<PromptInputMask> = { char: "*", lastVisible: false };

export function prompt(optsOrMessage: PromptOptions | string, options?: Omit<PromptOptions, "message">) {
return maybePrompt(optsOrMessage, options).then(resultOrExit);
Expand Down Expand Up @@ -95,7 +95,7 @@ export function innerPrompt(
interface DrawState {
title: string;
inputText: string;
mask: InputMask | false;
mask: PromptInputMask | false;
hasCompleted: boolean;
}

Expand Down
15 changes: 13 additions & 2 deletions src/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ import {
writeAllSync,
} from "./deps.ts";

export type ExpandGlobOptions = import("./deps.ts").ExpandGlobOptions;
export type WalkOptions = import("./deps.ts").WalkOptions;
/**
* `ExpandGlobOptions` from https://deno.land/std/fs/expand_glob.ts
* @internal
*/
type DenoStdExpandGlobOptions = import("./deps.ts").ExpandGlobOptions;
export type ExpandGlobOptions = DenoStdExpandGlobOptions;
/**
* `WalkOptions` from https://deno.land/std/fs/walk.ts
* @internal
*/
type DenoStdWalkOptions = import("./deps.ts").WalkOptions;
export type WalkOptions = DenoStdWalkOptions;

const PERIOD_CHAR_CODE = ".".charCodeAt(0);

/** @internal */
export function createPathRef(path: string | URL | ImportMeta | PathRef): PathRef {
if (path instanceof PathRef) {
return path;
Expand Down
1 change: 1 addition & 0 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ export class RequestResult {
#downloadResponse: Response;
#originalUrl: string;

/** @internal */
constructor(opts: {
response: Response;
originalUrl: string;
Expand Down

0 comments on commit 31a8812

Please sign in to comment.