UNPKG

@ordino.ai/cli

Version:
75 lines (65 loc) 2.76 kB
import { renamePackageJsonName, createEnvFile, createGitIgnoreFile, copyTemplateFiles, updatePackageJsonEngine, copyWorkflowFile, copyInitializeFile, getBaseURL, getPlatformTypeString, getTemplateDirectories, } from "./boilerplateHelper"; import { CItype, Platformtype, Project } from "../models/models"; import { convertToValidPackageName } from "../prompts/prompts"; export type Environment = "staging" | "production" | "local"; async function createStandardBoilerplateUI( appPath: string, project: Project, includeSampleTest: boolean, token: string, needGitActionSetup: boolean, environment: Environment = "staging", platform: Platformtype ) { const baseURL = getBaseURL(environment); const platformtype = getPlatformTypeString(platform); const { templateDir, commonTemplateDir, frameworkCommonTemplateDir } = getTemplateDirectories(platformtype, 'ui'); copyTemplateFiles(templateDir, appPath, includeSampleTest, baseURL); copyTemplateFiles(commonTemplateDir, appPath, includeSampleTest, baseURL); copyTemplateFiles(frameworkCommonTemplateDir, appPath, includeSampleTest, baseURL); if(needGitActionSetup) copyWorkflowFile(appPath, platformtype, project.repositoryType, baseURL); renamePackageJsonName(appPath, convertToValidPackageName(project.name)); updatePackageJsonEngine(appPath, environment, platform); createEnvFile(appPath, token, project.id, environment == "production" ? '' : baseURL); createGitIgnoreFile(appPath); copyInitializeFile(appPath, environment, platformtype, baseURL); } async function createStandardBoilerplateAPI( appPath: string, project: Project, includeSampleTest: boolean, token: string, needGitActionSetup: boolean, environment: Environment = "staging", platform: Platformtype ) { const baseURL = getBaseURL(environment); const platformtype = getPlatformTypeString(platform); const { templateDir, commonTemplateDir, frameworkCommonTemplateDir } = getTemplateDirectories(platformtype, 'api'); copyTemplateFiles(templateDir, appPath, includeSampleTest, baseURL); copyTemplateFiles(commonTemplateDir, appPath, includeSampleTest, baseURL); copyTemplateFiles(frameworkCommonTemplateDir, appPath, includeSampleTest, baseURL); if(needGitActionSetup) copyWorkflowFile(appPath, platformtype, project.repositoryType, baseURL); renamePackageJsonName(appPath, convertToValidPackageName(project.name)); updatePackageJsonEngine(appPath, environment, platform); createEnvFile(appPath, token, project.id, environment == "production" ? '' : baseURL); createGitIgnoreFile(appPath); copyInitializeFile(appPath, environment, platformtype, baseURL); } export { createStandardBoilerplateUI, createStandardBoilerplateAPI };