@tpitre/story-ui 2.4.0 ā 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +366 -224
- package/dist/cli/setup.d.ts +1 -0
- package/dist/cli/setup.d.ts.map +1 -1
- package/dist/cli/setup.js +76 -20
- package/package.json +1 -1
- package/templates/production-app/src/App.tsx +377 -41
package/dist/cli/setup.d.ts
CHANGED
package/dist/cli/setup.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../cli/setup.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,iCAAiC,SA8ChD;
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../cli/setup.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,wBAAgB,iCAAiC,SA8ChD;AAiYD,MAAM,WAAW,YAAY;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC7C,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,wBAAsB,YAAY,CAAC,OAAO,GAAE,YAAiB,iBAqxB5D"}
|
package/dist/cli/setup.js
CHANGED
|
@@ -189,6 +189,30 @@ export default preview;
|
|
|
189
189
|
fs.writeFileSync(previewTsxPath, previewContent);
|
|
190
190
|
console.log(chalk.green(`ā
Created .storybook/preview.tsx with ${designSystem} provider setup`));
|
|
191
191
|
}
|
|
192
|
+
// LLM Provider configurations
|
|
193
|
+
const LLM_PROVIDERS = {
|
|
194
|
+
claude: {
|
|
195
|
+
name: 'Claude (Anthropic)',
|
|
196
|
+
envKey: 'ANTHROPIC_API_KEY',
|
|
197
|
+
models: ['claude-sonnet-4-20250514', 'claude-3-5-sonnet-20241022', 'claude-3-haiku-20240307'],
|
|
198
|
+
docsUrl: 'https://console.anthropic.com/',
|
|
199
|
+
description: 'Recommended - Best for complex reasoning and code quality'
|
|
200
|
+
},
|
|
201
|
+
openai: {
|
|
202
|
+
name: 'OpenAI (GPT-4)',
|
|
203
|
+
envKey: 'OPENAI_API_KEY',
|
|
204
|
+
models: ['gpt-4o', 'gpt-4-turbo', 'gpt-3.5-turbo'],
|
|
205
|
+
docsUrl: 'https://platform.openai.com/api-keys',
|
|
206
|
+
description: 'Versatile and fast'
|
|
207
|
+
},
|
|
208
|
+
gemini: {
|
|
209
|
+
name: 'Google Gemini',
|
|
210
|
+
envKey: 'GEMINI_API_KEY',
|
|
211
|
+
models: ['gemini-2.0-flash', 'gemini-1.5-pro', 'gemini-1.5-flash'],
|
|
212
|
+
docsUrl: 'https://aistudio.google.com/app/apikey',
|
|
213
|
+
description: 'Cost-effective with good performance'
|
|
214
|
+
}
|
|
215
|
+
};
|
|
192
216
|
// Design system installation configurations (organized by framework)
|
|
193
217
|
const DESIGN_SYSTEM_CONFIGS = {
|
|
194
218
|
// React design systems
|
|
@@ -544,14 +568,17 @@ export async function setupCommand(options = {}) {
|
|
|
544
568
|
console.log(chalk.yellow(`Valid options: ${validSystems.join(', ')}`));
|
|
545
569
|
process.exit(1);
|
|
546
570
|
}
|
|
571
|
+
const llmProvider = options.llmProvider || 'claude';
|
|
547
572
|
answers = {
|
|
548
573
|
designSystem,
|
|
549
574
|
installDesignSystem: !options.skipInstall && Object.keys(DESIGN_SYSTEM_CONFIGS).includes(designSystem),
|
|
550
575
|
generatedStoriesPath: './src/stories/generated/',
|
|
576
|
+
llmProvider,
|
|
551
577
|
mcpPort,
|
|
552
578
|
hasApiKey: false,
|
|
553
579
|
};
|
|
554
580
|
console.log(chalk.blue(`š¦ Design system: ${designSystem}`));
|
|
581
|
+
console.log(chalk.blue(`š¤ AI Provider: ${LLM_PROVIDERS[llmProvider]?.name || llmProvider}`));
|
|
555
582
|
console.log(chalk.blue(`š Generated stories: ${answers.generatedStoriesPath}`));
|
|
556
583
|
console.log(chalk.blue(`š MCP port: ${mcpPort}`));
|
|
557
584
|
if (options.skipInstall) {
|
|
@@ -623,16 +650,33 @@ export async function setupCommand(options = {}) {
|
|
|
623
650
|
return available ? true : `Port ${value} is already in use`;
|
|
624
651
|
}
|
|
625
652
|
},
|
|
653
|
+
{
|
|
654
|
+
type: 'list',
|
|
655
|
+
name: 'llmProvider',
|
|
656
|
+
message: 'Which AI provider would you like to use?',
|
|
657
|
+
choices: [
|
|
658
|
+
{ name: `${chalk.green('Claude (Anthropic)')} - ${chalk.gray('Recommended for complex reasoning and code quality')}`, value: 'claude' },
|
|
659
|
+
{ name: `${chalk.blue('OpenAI (GPT-4)')} - ${chalk.gray('Versatile and fast')}`, value: 'openai' },
|
|
660
|
+
{ name: `${chalk.yellow('Google Gemini')} - ${chalk.gray('Cost-effective with good performance')}`, value: 'gemini' }
|
|
661
|
+
],
|
|
662
|
+
default: 'claude'
|
|
663
|
+
},
|
|
626
664
|
{
|
|
627
665
|
type: 'confirm',
|
|
628
666
|
name: 'hasApiKey',
|
|
629
|
-
message:
|
|
667
|
+
message: (promptAnswers) => {
|
|
668
|
+
const provider = LLM_PROVIDERS[promptAnswers.llmProvider];
|
|
669
|
+
return `Do you have a ${provider?.name || 'provider'} API key? (You can add it later)`;
|
|
670
|
+
},
|
|
630
671
|
default: false
|
|
631
672
|
},
|
|
632
673
|
{
|
|
633
674
|
type: 'password',
|
|
634
675
|
name: 'apiKey',
|
|
635
|
-
message:
|
|
676
|
+
message: (promptAnswers) => {
|
|
677
|
+
const provider = LLM_PROVIDERS[promptAnswers.llmProvider];
|
|
678
|
+
return `Enter your ${provider?.name || 'provider'} API key:`;
|
|
679
|
+
},
|
|
636
680
|
when: (promptAnswers) => promptAnswers.hasApiKey,
|
|
637
681
|
validate: (input) => input.trim() ? true : 'API key is required'
|
|
638
682
|
}
|
|
@@ -906,6 +950,7 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
906
950
|
config.defaultAuthor = 'Story UI AI';
|
|
907
951
|
config.componentFramework = componentFramework; // react, angular, vue, svelte, or web-components
|
|
908
952
|
config.storybookFramework = storybookFramework; // e.g., @storybook/react-vite, @storybook/angular
|
|
953
|
+
config.llmProvider = answers.llmProvider || 'claude'; // claude, openai, or gemini
|
|
909
954
|
// Create configuration file
|
|
910
955
|
const configContent = `module.exports = ${JSON.stringify(config, null, 2)};`;
|
|
911
956
|
const configPath = path.join(process.cwd(), 'story-ui.config.js');
|
|
@@ -972,23 +1017,32 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
972
1017
|
console.log(chalk.green('ā
Created story-ui-docs/ directory structure'));
|
|
973
1018
|
console.log(chalk.gray(' Add your design system documentation to enhance AI story generation'));
|
|
974
1019
|
}
|
|
975
|
-
// Create .env file
|
|
976
|
-
const envSamplePath = path.resolve(__dirname, '../../.env.sample');
|
|
1020
|
+
// Create .env file with provider-specific configuration
|
|
977
1021
|
const envPath = path.join(process.cwd(), '.env');
|
|
1022
|
+
const selectedProvider = answers.llmProvider || 'claude';
|
|
1023
|
+
const providerConfig = LLM_PROVIDERS[selectedProvider];
|
|
978
1024
|
if (!fs.existsSync(envPath)) {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
1025
|
+
// Generate .env content based on selected provider
|
|
1026
|
+
let envContent = `# Story UI Configuration
|
|
1027
|
+
# Generated by: npx story-ui init
|
|
1028
|
+
|
|
1029
|
+
# LLM Provider: ${providerConfig?.name || selectedProvider}
|
|
1030
|
+
LLM_PROVIDER=${selectedProvider}
|
|
1031
|
+
|
|
1032
|
+
# API Key for ${providerConfig?.name || selectedProvider}
|
|
1033
|
+
# Get your key from: ${providerConfig?.docsUrl || 'your provider dashboard'}
|
|
1034
|
+
${providerConfig?.envKey || 'API_KEY'}=${answers.apiKey || 'your-api-key-here'}
|
|
1035
|
+
|
|
1036
|
+
# Story UI MCP Server Port
|
|
1037
|
+
VITE_STORY_UI_PORT=${answers.mcpPort || '4001'}
|
|
1038
|
+
|
|
1039
|
+
# Optional: Add additional provider keys if you want to switch providers later
|
|
1040
|
+
# ANTHROPIC_API_KEY=your-anthropic-key
|
|
1041
|
+
# OPENAI_API_KEY=your-openai-key
|
|
1042
|
+
# GEMINI_API_KEY=your-gemini-key
|
|
1043
|
+
`;
|
|
1044
|
+
fs.writeFileSync(envPath, envContent);
|
|
1045
|
+
console.log(chalk.green(`ā
Created .env file for ${providerConfig?.name || selectedProvider}${answers.apiKey ? ' with your API key' : ''}`));
|
|
992
1046
|
}
|
|
993
1047
|
else {
|
|
994
1048
|
console.log(chalk.yellow('ā ļø .env file already exists, skipping'));
|
|
@@ -1077,11 +1131,13 @@ Material UI (MUI) is a React component library implementing Material Design.
|
|
|
1077
1131
|
console.log(`š¦ Import path: ${chalk.cyan(config.importPath)}`);
|
|
1078
1132
|
}
|
|
1079
1133
|
if (!answers.apiKey) {
|
|
1080
|
-
|
|
1081
|
-
console.log('
|
|
1134
|
+
const provider = LLM_PROVIDERS[answers.llmProvider] || LLM_PROVIDERS.claude;
|
|
1135
|
+
console.log(chalk.yellow(`\nā ļø Don't forget to add your ${provider.name} API key to .env file!`));
|
|
1136
|
+
console.log(` Get your key from: ${provider.docsUrl}`);
|
|
1082
1137
|
}
|
|
1138
|
+
const providerName = LLM_PROVIDERS[answers.llmProvider]?.name || 'your LLM provider';
|
|
1083
1139
|
console.log('\nš Next steps:');
|
|
1084
|
-
console.log('1. ' + (answers.apiKey ? 'Start' :
|
|
1140
|
+
console.log('1. ' + (answers.apiKey ? 'Start' : `Add your ${providerName} API key to .env, then start`) + ' Story UI: npm run story-ui');
|
|
1085
1141
|
console.log('2. Start Storybook: npm run storybook');
|
|
1086
1142
|
console.log('3. Navigate to "Story UI > Story Generator" in your Storybook sidebar');
|
|
1087
1143
|
console.log('4. Start generating UI with natural language prompts!');
|