| feat(cli): zero yaml compile (#4116) ## Changes Contributes to https://linear.app/nango/issue/NAN-3242/new-compilation-and-deploy - CLI zero yaml compile Add full compilation for zero yaml. It's only to compile all, no support for nango dev yet. The files are split from the rest to avoid bloating the current services. - Typechecking: runs typescript checker, nothing crazy - Bundling: use esbuild to bundle files and imported files - Rebuild: virtual nango.yaml for deployment and dryrun later - Added missing types for Metadata - Added support for void and never - Clean up legacy code ## 🧪 Tests I don't yet provide an easy way for you to test, there are the fixtures for the test that's basically it but its missing the package.json, so if you are motivated you can add a package.json with nango and zod and run compile. The unit tests and snapshots are showing the expected output.  <!-- Summary by @propel-code-bot --> --- **feat(cli): Add Zero-Yaml Compilation Pipeline for Nango CLI** This major PR implements end-to-end CLI support for compiling 'zero-yaml' integration projects, enabling TypeScript-based integrations to be typechecked, bundled, and compiled without a nango.yaml file. Major new modules include an entry scanning/typecheck/build pipeline (with esbuild and custom Babel plugin), robust output post-processing, and definition/model reconstruction for deploy and validation, along with improved Nango type support (including void and never), upgrades to dependencies for esbuild/Babel, and comprehensive new unit/snapshot tests. Existing CLI entrypoints, pre-check, and error handling are refactored to route zero-yaml projects to the new pipeline while maintaining backward compatibility for legacy (yaml-based) projects. **Key Changes:** • Introduces zero-yaml compile workflow: `TypeScript` typechecking, esbuild bundling with Babel plugin, virtual nango.yaml reconstruction • Adds ``CLI`` detection and pipeline segregation for zero-yaml vs. yaml-based projects • Implements robust type/model parsing, including void/never and enhanced union/array/optional handling • Removes legacy and unused code (e.g., `isJsOrTsType`) • Refactors ``CLI`` compile command and error handling for improved clarity • Significant test additions: unit, fixtures, and snapshots for the new compile pipeline • Upgrades key dependencies (esbuild, babel, zod, types) and adds missing dev dependencies **Affected Areas:** • ``CLI`` zero-yaml compile pipeline (`zeroYaml`/compile.ts, `zeroYaml`/definitions.ts, `zeroYaml`/`zodToNango`.ts) • ``CLI`` command and entrypoint handling (index.ts) • Model and definition helpers/services • Test fixtures and helpers • runner-sdk typing for metadata/void/never • Package and dependency management **Potential Impact:** **Functionality**: Enables compiling/deploying zero-yaml projects, i.e. projects with entrypoint index.ts and no nango.yaml; introduces new error and handling logic for TypeScript-based integrations; legacy yaml integrations remain unaffected. **Performance**: esbuild/Babel pipeline may introduce additional build time for large projects but is only used in zero-yaml path; isolated from legacy workflow. **Security**: No direct security impact; code only produces intermediate deployment bundles and metadata, does not affect runtime execution or secrets. **Scalability**: Pipeline is modular and can handle multiple entrypoints and larger projects; design anticipates future dev server and further CLI tooling extensions. **Review Focus:** • Zero-yaml compile flow: correctness of entrypoint detection, typechecking, esbuild/Babel transpilation, and output structure • Type/model extraction and edge case handling in `zodToNango`.ts (void, never, optionals, unions/arrays, references) • Definition/model reconstruction logic (definitions.ts) and its robustness for deployment cycle • Dependency upgrade risks-especially with esbuild/Babel integration and cross-version compatibility • Modularization of compile steps and maintainability of `compileAll`/related functions <details> <summary><strong>Testing Needed</strong></summary> • Validate compile command on real-world zero-yaml projects (index.ts with syncs/actions/on-event scripts) • Review expected output for various `TypeScript` constructs (esp. with void/never/optionals/unions) • Manually test error paths for missing dependencies, export errors, or misconfigured project structures • Ensure backward compatibility by testing yaml-based project compilation and deploy • Inspect produced output (snapshot/unit tests, .nango folder, generated ``JSON``/``TS`` schemas) for correctness </details> <details> <summary><strong>Code Quality Assessment</strong></summary> **test coverage (unit, fixtures, snapshots)**: Thorough-covers key cases and new flows; easy to follow and extend. **packages/cli/lib/index.ts**: Clean routing for zero-yaml vs. yaml flows; improved error handling. **package.json/dependencies**: Properly updated and explicit; superfluous dev deps removed. **packages/cli/lib/zeroYaml/compile.ts**: Well-structured, logical phase separation (typecheck, bundle, rebuild, etc.), but compileAll remains large; good inline comments and error reporting. Suggest future further modularization. **packages/cli/lib/zeroYaml/definitions.ts**: Clear and modular; robust error-checking and type validation; legacy terminology ('Parsed') noted. **packages/cli/lib/zeroYaml/zodToNango.ts**: Comprehensive type guard coverage and readable conversions; accommodates difficult zod schema cases. </details> <details> <summary><strong>Best Practices</strong></summary> **Typescript**: • Strict compiler options and type safety • Full union/void/never/optional/array coverage **Testing**: • New unit, integration, and snapshot tests for zero-yaml pipeline • Good fixture design **Dependency Management**: • Explicit upgrades and types • Removes dead code/deps **Modularity**: • Compile pipeline segmented by phase, but could further improve function-level decomposition </details> <details> <summary><strong>Possible Issues</strong></summary> • Use of legacy internal terms like 'Parsed' and 'Definitions' may cause confusion and merit future refactor • Custom Babel transformation for create wrappers could be brittle-edge cases need ongoing monitoring as APIs evolve • Partial error messaging for missing deps/misconfigurations; improvement for onboarding may be required • Potential for esbuild/Babel config drift; futureproofing needs tight version locking/testing • nango.json output purpose is unclear and not thoroughly documented; clarify or document before wide adoption </details> --- *This summary was automatically generated by @propel-code-bot* | 1 年前 |