import {cd, path} from 'zx'
import {trim} from "licia";
import {run_deploy_batch, run_deploy_root, run_package, run_package_batch, run_upload} from "./library.js";

// 切换目录
cd(trim(path.dirname(import.meta.dirname)))
// 执行流程
try {
    await run_deploy_root()
    await run_deploy_batch([
        'service-common',
        'service-dependencies',
        'service-configuration',
        'service-forest',
        'service-cli',
        'service-cli/service-cli-core',
        'service-executor',
        'service-executor/service-executor-core',
        'utils/executor',
    ])
    await run_package_batch([
        'service-api',
        'service-check',
        'service-cli/service-cli-runner',
        'service-cloud-query',
        'service-executor/service-executor-manager',
        'service-executor/service-executor-task',
        'service-command',
        'service-command-pro',
        'service-exporter',
        'service-flink-query',
        'service-gateway',
        'service-hudi-query',
        'service-info-query',
        'service-monitor',
        'service-loki-query',
        'service-pulsar-query',
        'service-queue',
        'service-scheduler',
        'service-uploader',
        'service-web',
        'service-yarn-query',
        'service-zookeeper-query',
        'utils/patch',
        'utils/sync',
    ])
    for (const profile of ['b2a4', 'b2b1', 'b2b12']) {
        await run_package('service-launcher', profile)
        await run_upload(`**/service-launcher-${profile}-1.0.0-SNAPSHOT.jar`)
    }
    await run_upload('**/target/*-1.0.0-SNAPSHOT.jar')
} catch (e) {
    console.error(e)
}