@@ -26,6 +26,8 @@ import { diff } from 'jest-diff';
2626import type { GenerateOptions } from './types.js' ;
2727import { OPTION_TYPE , RuleModule } from './types.js' ;
2828import { replaceRulePlaceholder } from './rule-link.js' ;
29+ import { getEmojis } from 'gpt-emoji' ;
30+ import { table } from 'table' ;
2931
3032function stringOrArrayWithFallback < T extends string | readonly string [ ] > (
3133 stringOrArray : undefined | T ,
@@ -75,6 +77,8 @@ export async function generate(path: string, options?: GenerateOptions) {
7577 const ignoreDeprecatedRules =
7678 options ?. ignoreDeprecatedRules ??
7779 OPTION_DEFAULTS [ OPTION_TYPE . IGNORE_DEPRECATED_RULES ] ;
80+ const initEmojis =
81+ options ?. initEmojis ?? OPTION_DEFAULTS [ OPTION_TYPE . INIT_EMOJIS ] ;
7882 const initRuleDocs =
7983 options ?. initRuleDocs ?? OPTION_DEFAULTS [ OPTION_TYPE . INIT_RULE_DOCS ] ;
8084 const pathRuleDoc =
@@ -113,6 +117,22 @@ export async function generate(path: string, options?: GenerateOptions) {
113117 const urlRuleDoc =
114118 options ?. urlRuleDoc ?? OPTION_DEFAULTS [ OPTION_TYPE . URL_RULE_DOC ] ;
115119
120+ if ( initEmojis ) {
121+ if ( ! process . env . OPENAI_API_KEY ) {
122+ throw new Error ( 'Missing OPENAI_API_KEY environment variable.' ) ;
123+ }
124+ const configNames = Object . keys ( plugin . configs || { } ) ;
125+ const result = await getEmojis ( configNames , {
126+ count : 1 ,
127+ } ) ;
128+ const data = [
129+ [ 'Config' , 'Emoji' ] ,
130+ ...configNames . map ( ( configName , i ) => [ configName , result [ i ] ] ) ,
131+ ] ;
132+ console . log ( table ( data ) ) ;
133+ return ;
134+ }
135+
116136 // Gather normalized list of rules.
117137 const ruleNamesAndRules = Object . entries ( plugin . rules )
118138 . map ( ( [ name , ruleModule ] ) => {
0 commit comments