import { outputFileSync } from "fs-extra" ; const gulp = require ( "gulp" ) ; import { argv } from "yargs" ; import { getObjectsInfoByType } from "../common/base" ; import { getPathFromObjectInfo , getObjectTypes } from "../common/dbobject" ; import { isGlobMatch } from "../common/globs" ; import { exportFilesFromDbAsync } from "./import" ; import { workspaceConfig as config } from "../common/config" ; import { dbConfig } from "../common/config" ; const createSrcFromDbObjects = async ( { env = argv . env || "DEV" , file = argv . file } ) => { const source = file || config . get ( { field : "source.input" , env } ) ; const schemas = dbConfig . getSchemas ( ) ; const objectTypes = getObjectTypes ( ) ; try { for ( const owner of schemas ) { const objs = await getObjectsInfoByType ( env , owner , objectTypes ) ; for ( const obj of objs ) { const path = getPathFromObjectInfo ( owner , obj . OBJECT_TYPE , obj . OBJECT_NAME ) ; if ( path !== "" ) { if ( isGlobMatch ( source , [ path ] ) ) { outputFileSync ( path , "" ) ; console . log ( "Created file " + path ) ; } } } } } catch ( error ) { console . error ( error . message ) ; } } ; export async function createTask ( ) { return gulp . series ( createSrcFromDbObjects , exportFilesFromDbAsync ) ( ) ; }