export async function handleDeploy()

in src/commands/deploy/index.ts [87:140]


export async function handleDeploy(argv: ArgumentsCamelCase) {
  if (!checkDirectory()) {
    return;
  }

  const projectConfig = getProjectConfig();
  if (!projectConfig) return logger.notInProject();

  const isSuccess = await checkIsLoginSuccess();
  if (!isSuccess) return;

  const server = await ApiService.getInstance();
  const entry = argv.entry as string;
  await checkRoutineExist(projectConfig.name, entry);

  const req: GetRoutineReq = { Name: projectConfig.name };
  const routineDetail = await server.getRoutine(req, false);

  const versionList: CodeVersionProps[] =
    routineDetail?.data?.CodeVersions || [];

  const customEntry = argv.entry as string;

  const stagingVersion = routineDetail?.data?.Envs[1]?.CodeVersion;
  const productionVersion = routineDetail?.data?.Envs[0]?.CodeVersion;
  if (argv.quick) {
    await quickDeploy(customEntry, projectConfig);
    exit(0);
  }

  if (versionList.length === 0) {
    logger.log(
      t('no_formal_version_found').d(
        'No formal version found, you need to create a version first.'
      )
    );
    await handleOnlyUnstableVersionFound(projectConfig, customEntry);
  } else {
    await displayVersionList(versionList, stagingVersion, productionVersion);
    logger.log(
      chalk.bold(
        `${t('deploy_version_select').d('Select the version you want to publish')}:`
      )
    );
    const selectedVersion = await promptSelectVersion(versionList);
    const selectedType = await displaySelectDeployType();

    await deploySelectedCodeVersion(
      projectConfig.name,
      selectedType,
      selectedVersion
    );
  }
}