|
| 1 | +/** @jsx geckoJSX */ |
| 2 | +/** @jsxFrag geckoJSX */ |
| 3 | + |
| 4 | +import { FileFormatter, Folder, Root, geckoJSX } from '@flatfile/gecko' |
| 5 | +import prompts from 'prompts' |
| 6 | +import { ChangelogFile } from './templates/Changelog' |
| 7 | +import { IndexFile } from './templates/IndexFile' |
| 8 | +import { PackageJsonFile } from './templates/PackageJson' |
| 9 | +import { ReadmeFile } from './templates/Readme' |
| 10 | + |
| 11 | +export default async function () { |
| 12 | + const response = await prompts([ |
| 13 | + { |
| 14 | + type: 'text', |
| 15 | + name: 'name', |
| 16 | + message: 'Name?', |
| 17 | + format: (value: string) => value.trim(), |
| 18 | + validate: (value: string) => |
| 19 | + value.trim() === '' ? 'A name must be provided' : true, |
| 20 | + }, |
| 21 | + { |
| 22 | + type: 'text', |
| 23 | + name: 'description', |
| 24 | + message: 'Description', |
| 25 | + format: (value: string) => (value ? value.trim() : ''), |
| 26 | + }, |
| 27 | + { |
| 28 | + type: 'select', |
| 29 | + name: 'category', |
| 30 | + message: 'Category', |
| 31 | + choices: [ |
| 32 | + { title: 'Export', value: 'plugin' }, |
| 33 | + { title: 'Transform', value: 'transform' }, |
| 34 | + { title: 'Automation', value: 'automation' }, |
| 35 | + { title: 'Records', value: 'records' }, |
| 36 | + { title: 'Extractors', value: 'extractors' }, |
| 37 | + { title: 'Utilities', value: 'utilities' }, |
| 38 | + { title: 'Core', value: 'core' }, |
| 39 | + { |
| 40 | + title: 'Schema Converters', |
| 41 | + value: 'schema-converters', |
| 42 | + }, |
| 43 | + { title: 'Connect', value: 'connect' }, |
| 44 | + { title: 'Egress', value: 'egress' }, |
| 45 | + ], |
| 46 | + }, |
| 47 | + { |
| 48 | + type: 'text', |
| 49 | + name: 'job', |
| 50 | + message: 'Job', |
| 51 | + format: (value: string) => value.trim(), |
| 52 | + validate: (value: string) => |
| 53 | + value.trim() === '' ? 'A job must be provided' : true, |
| 54 | + }, |
| 55 | + { |
| 56 | + type: 'text', |
| 57 | + name: 'author', |
| 58 | + message: 'Author', |
| 59 | + format: (value: string) => (value ? value.trim() : ''), |
| 60 | + }, |
| 61 | + ]) |
| 62 | + |
| 63 | + console.log(response) |
| 64 | + |
| 65 | + return ( |
| 66 | + <Root path={`../../plugins/${response.name}`} erase> |
| 67 | + <FileFormatter formatter='prettier' match='*.{js,ts,yaml}'> |
| 68 | + <Folder name='src'> |
| 69 | + <IndexFile job={response.job} /> |
| 70 | + </Folder> |
| 71 | + <PackageJsonFile |
| 72 | + pluginName={response.name} |
| 73 | + description={response.description} |
| 74 | + category={response.category} |
| 75 | + author={response.author} |
| 76 | + /> |
| 77 | + <ReadmeFile pluginName={response.name} /> |
| 78 | + <ChangelogFile pluginName={response.name} /> |
| 79 | + </FileFormatter> |
| 80 | + </Root> |
| 81 | + ) |
| 82 | +} |
0 commit comments