Skip to content

Commit

Permalink
feat: add support for more patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewgallo committed Nov 20, 2024
1 parent 5e1f594 commit 0d360db
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
export const INLINE = 'Inline';
export const FULL = 'Full Vite template';
export const DATA_TABLE = 'Data table';
export const TEARSHEET = 'Tearsheet';
24 changes: 21 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,31 @@ import path from 'path';

import { reactExamples } from './tanstack-react-list';
import { installDependencies } from './utils/installDependencies';
import { INLINE, FULL } from './constants';
import { INLINE, FULL, DATA_TABLE, TEARSHEET } from './constants';
import { successMessage } from './utils/successMessage';
import { readTempJSFileImports } from './utils/readTempJSFileImports';
import { tearsheetPatterns } from './tearsheet-patterns';

const runPrompt = async () => {
const patternType = await select({
message: 'Select a type of pattern',
choices: [
{
name: DATA_TABLE,
value: DATA_TABLE,
description: 'Choose from a variety of different data table extensions',
},
{
name: TEARSHEET,
value: TEARSHEET,
description: 'Choose from a variety of different tearsheet patterns',
},
],
});
const answers = {
pattern: await select({
message: 'Select a data table pattern',
choices: reactExamples,
choices: patternType === DATA_TABLE ? reactExamples : tearsheetPatterns,
}),
installDeps: await confirm({ message: 'Install required dependencies?' }),
customPath: await input({
Expand All @@ -43,7 +59,9 @@ const runPrompt = async () => {

const { pattern, customPath, installDeps, type } = answers;

const { url } = reactExamples.find((e) => e.value === pattern)!;
const chosenPatterns =
patternType === DATA_TABLE ? reactExamples : tearsheetPatterns;
const { url } = chosenPatterns.find((e) => e.value === pattern)!;

const finalDestination =
typeof customPath === 'string' && customPath.length > 0
Expand Down
16 changes: 16 additions & 0 deletions src/tearsheet-patterns.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// import { Separator } from '@inquirer/prompts';

export const tearsheetPatterns = [
{
name: 'tearsheet-step-flow',
value: 'tearsheet-step-flow',
description: 'https://github.com/matthewgallo/tearsheet-step-flow',
url: 'matthewgallo/tearsheet-step-flow',
},
{
name: 'More coming soon',
value: 'More coming soon',
url: 'N/A',
disabled: true,
},
];

0 comments on commit 0d360db

Please sign in to comment.