import { Utils , FileSystem } from "@slicemachine/core" ; import { installRequiredDependencies , validatePkg , maybeExistingRepo , createRepository , loginOrBypass , configureProject , displayFinalMessage , detectFramework , } from "./steps" ; import { findArgument } from "./utils" ; async function init ( ) { const cwd = findArgument ( process . argv , "cwd" ) || process . cwd ( ) ; const base = ( findArgument ( process . argv , "base" ) || Utils . CONSTS . DEFAULT_BASE ) as Utils . Endpoints . Base ; console . log ( Utils . purple ( "You're about to configure Slicemachine... Press ctrl + C to cancel" ) ) ; validatePkg ( cwd ) ; await loginOrBypass ( base ) ; const config = FileSystem . getOrCreateAuthConfig ( ) ; const frameworkResult = await detectFramework ( cwd ) ; const { existing , name } = await maybeExistingRepo ( config . cookies , cwd , config . base ) ; if ( ! existing ) { await createRepository ( name , frameworkResult . value , config ) ; } await installRequiredDependencies ( cwd , frameworkResult . value ) ; configureProject ( cwd , base , name , frameworkResult ) ; displayFinalMessage ( cwd ) ; } try { void init ( ) ; } catch ( error ) { if ( error instanceof Error ) Utils . writeError ( error . message ) ; else console . error ( error ) ; }