Skip to content

Commit

Permalink
feat: support env display
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Aug 30, 2021
1 parent 9703aa3 commit 446af15
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/exported.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export { generateTableChoices } from './util';
export { Deployable, Deployer } from './deployer';
export { Prompter } from './prompter';
export { runHook, SfHook } from './hooks';
export { JsonObject, TableObject } from './types';
6 changes: 3 additions & 3 deletions src/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { Hook, Hooks } from '@oclif/core/lib/interfaces/hooks';
import { cli } from 'cli-ux';
import { Duration, env } from '@salesforce/kit';
import { Deployer } from './deployer';
import { EnvList, EnvDisplay, DataObject, Deploy, Login } from './types';
import { EnvList, EnvDisplay, JsonObject, Deploy, Login, TableObject } from './types';

interface SfHooks<T = unknown> extends Hooks {
'sf:env:list': EnvList.HookMeta<T & DataObject>;
'sf:env:display': EnvDisplay.HookMeta<T & DataObject>;
'sf:env:list': EnvList.HookMeta<T & TableObject>;
'sf:env:display': EnvDisplay.HookMeta<T & JsonObject>;
'sf:deploy': Deploy.HookMeta<T & Deployer>;
'sf:login': Login.HookMeta;
}
Expand Down
20 changes: 14 additions & 6 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,27 @@

import { Deployer } from '../deployer';

export type DataObject = {
[key: string]: string | boolean;
export type JsonObject = {
[key: string]: string | string[] | number | number[] | boolean | boolean[] | null | undefined;
};

/**
* Describes an object that is intended to be rendered in a table, which requires
* that no value is an array.
*/
export type TableObject = {
[key: string]: string | number | boolean | null | undefined;
};

export namespace EnvDisplay {
export type HookMeta<T extends DataObject> = {
options: {};
export type HookMeta<T extends JsonObject> = {
options: { targetEnv: string };
return: T;
};
}

export namespace EnvList {
type Table<T extends DataObject> = {
type Table<T extends TableObject> = {
data: T[];
columns: Array<keyof T>;
title: string;
Expand All @@ -29,7 +37,7 @@ export namespace EnvList {
all: boolean;
};

export type HookMeta<T extends DataObject> = {
export type HookMeta<T extends TableObject> = {
options: Options;
return: Array<Table<T>>;
};
Expand Down

0 comments on commit 446af15

Please sign in to comment.