-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #87 from elsoul/firestore
add skeet firestore
- Loading branch information
Showing
9 changed files
with
541 additions
and
262 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,60 @@ | ||
import { DEFAULT_FUNCTION_NAME } from '@/index' | ||
import { SkeetAI } from '@skeet-framework/ai' | ||
import chalk from 'chalk' | ||
import * as readline from 'readline' | ||
import { promptUser } from '../ai' | ||
import { yesOrNoMode } from './yesOrNoMode' | ||
import { spawnSync } from 'child_process' | ||
import { appendFileSync, writeFileSync } from 'fs' | ||
import { FUNCTIONS_PATH } from '@/lib' | ||
import { NamingEnum } from '@skeet-framework/ai' | ||
|
||
export const firestoreMode = async ( | ||
skeetAi: SkeetAI, | ||
rl: readline.Interface | ||
) => { | ||
console.log(chalk.cyan('🔥 Firestore Model Generating Mode 🔥')) | ||
console.log(chalk.white(`Please describe your Firestore use case.`)) | ||
rl?.question(chalk.green('\nYou: '), async (input: string) => { | ||
const aiAnswer = (await skeetAi.firestore(input)) as string | ||
const modelFileSuggestion = (await skeetAi.naming( | ||
aiAnswer, | ||
NamingEnum.MODEL | ||
)) as string | ||
console.log( | ||
chalk.blue( | ||
'Skeet:' + | ||
chalk.white(' How about this one?\n\n') + | ||
`${chalk.white(`\`\`\`${modelFileSuggestion}\n`)}` + | ||
chalk.white(aiAnswer) + | ||
`${chalk.white('\n```')}` | ||
) | ||
) | ||
const text = `\n❓ May I create ${chalk.green( | ||
modelFileSuggestion | ||
)} file for you? (Yes/No) ` | ||
const isYes = (await yesOrNoMode(rl, text)) as boolean | ||
if (!isYes) { | ||
firestoreMode(skeetAi, rl) | ||
return | ||
} | ||
|
||
const modelFilePath = `${FUNCTIONS_PATH}/${DEFAULT_FUNCTION_NAME}/src/models/${modelFileSuggestion}` | ||
const modelIndexPath = `${FUNCTIONS_PATH}/${DEFAULT_FUNCTION_NAME}/src/models/index.ts` | ||
appendFileSync(modelIndexPath, `\nexport * from './${modelFileSuggestion}'`) | ||
writeFileSync(modelFilePath, aiAnswer) | ||
console.log(chalk.white(`\nCreated: ${modelFilePath}`)) | ||
console.log(chalk.white(`\nThen run:`), chalk.green(`$ skeet sync models`)) | ||
const syncText = '\n❓ Do you want me to sync models now? (Yes/No) ' | ||
const runSync = (await yesOrNoMode(rl, syncText)) as boolean | ||
if (runSync) { | ||
spawnSync(`skeet sync models`, { | ||
stdio: 'inherit', | ||
shell: true, | ||
}) | ||
} | ||
console.log(chalk.white(`\nExiting Firestore Mode...\n`)) | ||
promptUser(skeetAi.initOptions) | ||
}) | ||
return | ||
} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -1017,10 +1017,10 @@ | |
dependencies: | ||
"@sinonjs/commons" "^3.0.0" | ||
|
||
"@skeet-framework/[email protected].11": | ||
version "1.4.11" | ||
resolved "https://registry.yarnpkg.com/@skeet-framework/ai/-/ai-1.4.11.tgz#4a3db1e7072b6108b9cc922e265830abba9b7823" | ||
integrity sha512-U8xEu6wcgUhhkV8aHPOVa6dweg9vDa0uSgO6yrj5UVx2RnJWyi1DuayvFUbK/WULictAzhwQMGlrSeuBKdF5Wg== | ||
"@skeet-framework/ai@^1.4.15": | ||
version "1.4.15" | ||
resolved "https://registry.yarnpkg.com/@skeet-framework/ai/-/ai-1.4.15.tgz#60b9e41c77a2d1ceaa314b0fe27344288705cb54" | ||
integrity sha512-RHoUKH9SzKOqtkjuBbqrVd60GZjYcC77T75ZQFxByLecBf3OSXT+n1cH3iLKmbLS5bdi4yNF6R8R4GGDZY8THQ== | ||
dependencies: | ||
"@google-cloud/aiplatform" "2.17.0" | ||
"@google-cloud/translate" "7.2.2" | ||
|