nativeview-cli 0.1.0-rc.1

Developer CLI (`nv`) for Native View Engine: dev hot-reload, builds, pairing, SDK management, app scaffolding, and docs.
Documentation
//! Thin CLI adapter over `nativeview_codegen::targets::export_pkg` manifest and anchor emitters.

use nativeview_cli::manifest::NvManifest;
use nativeview_codegen::{
    ExportPackageMeta, HybridFileSpec, emit_android_library_manifest_xml as cg_android_manifest,
    emit_apple_export_anchor_h as cg_anchor_h, emit_apple_export_anchor_m as cg_anchor_m,
    emit_nitro_android_build_gradle as cg_nitro_gradle,
    emit_nitro_package_swift as cg_nitro_package_swift, emit_nitro_pkg_index_ts as cg_nitro_index,
    emit_nitro_pkg_package_json as cg_nitro_pkg_json,
    emit_rn_android_build_gradle as cg_rn_gradle, emit_rn_pkg_index_ts as cg_rn_index,
    emit_rn_pkg_package_json as cg_rn_pkg_json, emit_rn_podspec as cg_rn_podspec,
    emit_web_pkg_index_ts as cg_web_index, emit_web_pkg_package_json as cg_web_pkg_json,
    emit_web_pkg_tsconfig_json as cg_web_tsconfig,
};

use super::ExportContext;

fn export_meta(ctx: &ExportContext) -> ExportPackageMeta<'_> {
    ExportPackageMeta {
        npm_package_name: &ctx.npm_package_name,
        version: &ctx.version,
        primary_view_name: &ctx.primary_view_name,
        ios_module_name: &ctx.ios_module_name,
        android_package: &ctx.android_package,
    }
}

pub(crate) fn emit_web_pkg_index_ts(spec: &HybridFileSpec) -> Result<String, String> {
    cg_web_index(spec).map_err(|e| e.to_string())
}

pub(crate) fn emit_web_pkg_package_json(ctx: &ExportContext) -> Result<String, String> {
    cg_web_pkg_json(&export_meta(ctx)).map_err(|e| e.to_string())
}

pub(crate) fn emit_web_pkg_tsconfig_json() -> Result<String, String> {
    cg_web_tsconfig().map_err(|e| e.to_string())
}

pub(crate) fn emit_rn_pkg_index_ts(spec: &HybridFileSpec) -> Result<String, String> {
    cg_rn_index(spec).map_err(|e| e.to_string())
}

pub(crate) fn emit_rn_pkg_package_json(ctx: &ExportContext) -> Result<String, String> {
    cg_rn_pkg_json(&ctx.spec, &export_meta(ctx)).map_err(|e| e.to_string())
}

pub(crate) fn emit_rn_podspec(
    ctx: &ExportContext,
    manifest: &NvManifest,
) -> Result<String, String> {
    cg_rn_podspec(&ctx.ios_module_name, manifest.apple.resolved_rn_min_ios())
        .map_err(|e| e.to_string())
}

pub(crate) fn emit_rn_android_build_gradle(
    ctx: &ExportContext,
    manifest: &NvManifest,
) -> Result<String, String> {
    cg_rn_gradle(
        &ctx.android_package,
        manifest.android.min_sdk,
        manifest.android.target_sdk,
    )
    .map_err(|e| e.to_string())
}

pub(crate) fn emit_android_library_manifest_xml() -> Result<String, String> {
    cg_android_manifest().map_err(|e| e.to_string())
}

pub(crate) fn emit_nitro_pkg_index_ts(spec: &HybridFileSpec) -> Result<String, String> {
    cg_nitro_index(spec).map_err(|e| e.to_string())
}

pub(crate) fn emit_nitro_pkg_package_json(ctx: &ExportContext) -> Result<String, String> {
    cg_nitro_pkg_json(&export_meta(ctx)).map_err(|e| e.to_string())
}

pub(crate) fn emit_nitro_package_swift(
    ctx: &ExportContext,
    manifest: &NvManifest,
) -> Result<String, String> {
    cg_nitro_package_swift(
        &ctx.spec,
        &ctx.ios_module_name,
        manifest.apple.resolved_nitro_min_ios(),
    )
    .map_err(|e| e.to_string())
}

pub(crate) fn emit_nitro_android_build_gradle() -> Result<String, String> {
    cg_nitro_gradle().map_err(|e| e.to_string())
}

pub(crate) fn emit_apple_export_anchor_h(ctx: &ExportContext) -> Result<String, String> {
    cg_anchor_h(&ctx.spec).map_err(|e| e.to_string())
}

pub(crate) fn emit_apple_export_anchor_m(ctx: &ExportContext) -> Result<String, String> {
    cg_anchor_m(&ctx.spec, &ctx.ios_module_name).map_err(|e| e.to_string())
}