-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7125a02
commit 084263c
Showing
10 changed files
with
764 additions
and
10,281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** @jsx geckoJSX */ | ||
/** @jsxFrag geckoJSX */ | ||
|
||
import { FileFormatter, Folder, Root, geckoJSX } from '@flatfile/gecko' | ||
import prompts from 'prompts' | ||
import { ChangelogFile } from './templates/Changelog' | ||
import { IndexFile } from './templates/IndexFile' | ||
import { PackageJsonFile } from './templates/PackageJson' | ||
import { ReadmeFile } from './templates/Readme' | ||
|
||
export default async function () { | ||
const response = await prompts([ | ||
{ | ||
type: 'text', | ||
name: 'name', | ||
message: 'Name?', | ||
format: (value: string) => value.trim(), | ||
validate: (value: string) => | ||
value.trim() === '' ? 'A name must be provided' : true, | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'description', | ||
message: 'Description', | ||
format: (value: string) => (value ? value.trim() : ''), | ||
}, | ||
{ | ||
type: 'select', | ||
name: 'category', | ||
message: 'Category', | ||
choices: [ | ||
{ title: 'Export', value: 'plugin' }, | ||
{ title: 'Transform', value: 'transform' }, | ||
{ title: 'Automation', value: 'automation' }, | ||
{ title: 'Records', value: 'records' }, | ||
{ title: 'Extractors', value: 'extractors' }, | ||
{ title: 'Utilities', value: 'utilities' }, | ||
{ title: 'Core', value: 'core' }, | ||
{ | ||
title: 'Schema Converters', | ||
value: 'schema-converters', | ||
}, | ||
{ title: 'Connect', value: 'connect' }, | ||
{ title: 'Egress', value: 'egress' }, | ||
], | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'job', | ||
message: 'Job', | ||
format: (value: string) => value.trim(), | ||
validate: (value: string) => | ||
value.trim() === '' ? 'A job must be provided' : true, | ||
}, | ||
{ | ||
type: 'text', | ||
name: 'author', | ||
message: 'Author', | ||
format: (value: string) => (value ? value.trim() : ''), | ||
}, | ||
]) | ||
|
||
console.log(response) | ||
|
||
return ( | ||
<Root path={`../../plugins/${response.name}`} erase> | ||
<FileFormatter formatter='prettier' match='*.{js,ts,yaml}'> | ||
<Folder name='src'> | ||
<IndexFile job={response.job} /> | ||
</Folder> | ||
<PackageJsonFile | ||
pluginName={response.name} | ||
description={response.description} | ||
category={response.category} | ||
author={response.author} | ||
/> | ||
<ReadmeFile pluginName={response.name} /> | ||
<ChangelogFile pluginName={response.name} /> | ||
</FileFormatter> | ||
</Root> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"name": "@flatfile/gecko-codegen-plugins", | ||
"private": true, | ||
"scripts": { | ||
"format": "npx prettier -w **/*.{js,json,ts,tsx,yaml}", | ||
"gecko": "gecko \"$@\"" | ||
}, | ||
"dependencies": { | ||
"@flatfile/gecko": "latest", | ||
"tsconfig-paths": "^4.2.0", | ||
"tsx": "^4.10.2", | ||
"prompts": "^2.4.2" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** @jsx geckoJSX */ | ||
/** @jsxFrag geckoJSX */ | ||
|
||
import { File, Text, geckoJSX } from '@flatfile/gecko' | ||
|
||
export function ChangelogFile(props: { | ||
pluginName: string | ||
}) { | ||
return ( | ||
<File name="CHANGELOG.md"> | ||
<Text> | ||
{`# @flatfile/plugin-${props.pluginName}`} | ||
</Text> | ||
</File> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** @jsx geckoJSX */ | ||
/** @jsxFrag geckoJSX */ | ||
|
||
import { File, Text, geckoJSX } from '@flatfile/gecko' | ||
|
||
export function IndexFile(props: { job: string }) { | ||
return ( | ||
<File name="index.ts"> | ||
<Text>{`import type { Flatfile } from '@flatfile/api'`}</Text> | ||
<Text>{`import type { FlatfileEvent } from '@flatfile/listener'`}</Text> | ||
<Text /> | ||
<Text>{`import { FlatfileClient } from '@flatfile/api'`}</Text> | ||
<Text>{`import { jobHandler } from '@flatfile/plugin-job-handler'`}</Text> | ||
<Text /> | ||
<Text>const api = new FlatfileClient()</Text> | ||
<Text /> | ||
<Text> | ||
{`export default jobHandler( | ||
'${props.job}', | ||
async ( | ||
event: FlatfileEvent, | ||
tick: ( | ||
progress: number, | ||
message?: string | ||
) => Promise<Flatfile.JobResponse> | ||
) => { | ||
} | ||
)`} | ||
</Text> | ||
<Text /> | ||
</File> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** @jsx geckoJSX */ | ||
/** @jsxFrag geckoJSX */ | ||
|
||
import { File, Text, geckoJSX } from '@flatfile/gecko' | ||
|
||
export function PackageJsonFile(props: { | ||
pluginName: string | ||
description?: string | ||
category: string | ||
author?: string | ||
}) { | ||
return ( | ||
<File name="package.json"> | ||
<Text> | ||
{`{ | ||
"name": "@flatfile/plugin-${props.pluginName}", | ||
"version": "0.0.0", | ||
"url": "https://github.com/FlatFilers/flatfile-plugins/tree/main/plugins/${props.pluginName}", | ||
"description": "${props.description}", | ||
"registryMetadata": { | ||
"category": "${props.category}" | ||
}, | ||
"engines": { | ||
"node": ">= 16" | ||
}, | ||
"source": "src/index.ts", | ||
"main": "dist/main.js", | ||
"module": "dist/module.mjs", | ||
"types": "dist/types.d.ts", | ||
"scripts": { | ||
"build": "parcel build", | ||
"build:watch": "parcel watch", | ||
"build:prod": "NODE_ENV=production parcel build", | ||
"check": "tsc ./**/*.ts --noEmit --esModuleInterop", | ||
"test": "jest --passWithNoTests" | ||
}, | ||
"keywords": [ | ||
"flatfile-plugins", | ||
"category-${props.category}" | ||
], | ||
"author": "${props.author}", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/FlatFilers/flatfile-plugins.git", | ||
"directory": "plugins/${props.pluginName}" | ||
}, | ||
"license": "ISC", | ||
"dependencies": { | ||
}, | ||
"peerDependencies": { | ||
"@flatfile/api": "^1.8.0", | ||
"@flatfile/listener": "^1.0.1" | ||
} | ||
} | ||
`} | ||
</Text> | ||
</File> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** @jsx geckoJSX */ | ||
/** @jsxFrag geckoJSX */ | ||
|
||
import { File, Text, geckoJSX } from '@flatfile/gecko' | ||
|
||
export function ReadmeFile(props: { pluginName: string }) { | ||
return ( | ||
<File name="README.md"> | ||
<Text> | ||
{`# @flatfile/plugin-${props.pluginName}`} | ||
</Text> | ||
</File> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"jsx": "react", | ||
"jsxFactory": "geckoJSX", | ||
"jsxFragmentFactory": "geckoJSX" | ||
} | ||
} |
Oops, something went wrong.