@fern-api/generator-migrations 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +145 -528
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -603,156 +603,155 @@ function migrateConfig(config, updater) {
|
|
|
603
603
|
}
|
|
604
604
|
|
|
605
605
|
//#endregion
|
|
606
|
-
//#region src/generators/
|
|
606
|
+
//#region src/generators/csharp/migrations/1.0.0.ts
|
|
607
|
+
const migration_1_0_0$2 = {
|
|
608
|
+
version: "1.0.0",
|
|
609
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
610
|
+
draft["root-namespace-for-core-classes"] ??= false;
|
|
611
|
+
draft["pascal-case-environments"] ??= false;
|
|
612
|
+
draft["simplify-object-dictionaries"] ??= false;
|
|
613
|
+
}),
|
|
614
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
615
|
+
};
|
|
616
|
+
|
|
617
|
+
//#endregion
|
|
618
|
+
//#region src/generators/csharp/migrations/2.0.0.ts
|
|
619
|
+
const migration_2_0_0$2 = {
|
|
620
|
+
version: "2.0.0",
|
|
621
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
622
|
+
if ("experimental-additional-properties" in draft) {
|
|
623
|
+
const value = draft["experimental-additional-properties"];
|
|
624
|
+
delete draft["experimental-additional-properties"];
|
|
625
|
+
draft["additional-properties"] = value;
|
|
626
|
+
}
|
|
627
|
+
if ("experimental-enable-forward-compatible-enums" in draft) {
|
|
628
|
+
const value = draft["experimental-enable-forward-compatible-enums"];
|
|
629
|
+
delete draft["experimental-enable-forward-compatible-enums"];
|
|
630
|
+
draft["enable-forward-compatible-enums"] = value;
|
|
631
|
+
}
|
|
632
|
+
draft["additional-properties"] ??= false;
|
|
633
|
+
draft["enable-forward-compatible-enums"] ??= false;
|
|
634
|
+
draft["generate-mock-server-tests"] ??= false;
|
|
635
|
+
draft["inline-path-parameters"] ??= false;
|
|
636
|
+
draft["simplify-object-dictionaries"] ??= true;
|
|
637
|
+
draft["use-discriminated-unions"] ??= false;
|
|
638
|
+
}),
|
|
639
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/generators/csharp/migrations/index.ts
|
|
607
644
|
/**
|
|
608
|
-
* Migration for
|
|
609
|
-
*
|
|
610
|
-
* ## Context
|
|
611
|
-
*
|
|
612
|
-
* Version 1.0.0 introduced new defaults to improve the developer experience and modernize
|
|
613
|
-
* the generated SDK. These changes make the SDK more ergonomic and reduce boilerplate,
|
|
614
|
-
* but could break existing code that relied on the old defaults.
|
|
615
|
-
*
|
|
616
|
-
* To ensure backwards compatibility during upgrades, this migration explicitly sets the
|
|
617
|
-
* old defaults for users upgrading from pre-1.0.0 versions. This allows their existing
|
|
618
|
-
* code to continue working without changes.
|
|
619
|
-
*
|
|
620
|
-
* ## Changed Defaults
|
|
621
|
-
*
|
|
622
|
-
* | Field | Old Default (pre-1.0.0) | New Default (1.0.0+) | Impact |
|
|
623
|
-
* |-------|-------------------------|----------------------|--------|
|
|
624
|
-
* | `inlineFileProperties` | `false` | `true` | File upload properties are now inlined into request types |
|
|
625
|
-
* | `inlinePathParameters` | `false` | `true` | Path parameters are now inlined into method signatures |
|
|
626
|
-
* | `enableInlineTypes` | `false` | `true` | Type definitions are inlined where beneficial |
|
|
627
|
-
* | `noSerdeLayer` | `false` | `true` | Serialization/deserialization layer is removed for simpler types |
|
|
628
|
-
* | `omitUndefined` | `false` | `true` | Undefined values are omitted from JSON output |
|
|
629
|
-
* | `skipResponseValidation` | `false` | `true` | Response validation is skipped for better performance |
|
|
630
|
-
* | `useLegacyExports` | `true` | `false` | Modern ESM exports are used instead of legacy CommonJS |
|
|
631
|
-
*
|
|
632
|
-
* ## Migration Strategy
|
|
633
|
-
*
|
|
634
|
-
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
635
|
-
* values that are explicitly undefined. This means:
|
|
636
|
-
* - ✅ If a user has explicitly configured a field (even to the new default), that value is preserved
|
|
637
|
-
* - ✅ If a field is undefined, the old default is set for backwards compatibility
|
|
638
|
-
* - ✅ Unknown/custom fields are preserved
|
|
639
|
-
*
|
|
640
|
-
* ## Examples
|
|
641
|
-
*
|
|
642
|
-
* ### Example 1: Empty Config (Migration Applied)
|
|
645
|
+
* Migration module for C# SDK generator.
|
|
643
646
|
*
|
|
644
|
-
*
|
|
645
|
-
*
|
|
646
|
-
*
|
|
647
|
-
* - name: fernapi/fern-typescript-sdk
|
|
648
|
-
* version: 0.9.0
|
|
649
|
-
* config: {}
|
|
650
|
-
* ```
|
|
651
|
-
*
|
|
652
|
-
* **After Migration:**
|
|
653
|
-
* ```yaml
|
|
654
|
-
* generators:
|
|
655
|
-
* - name: fernapi/fern-typescript-sdk
|
|
656
|
-
* version: 1.0.0
|
|
657
|
-
* config:
|
|
658
|
-
* inlineFileProperties: false # Set by migration
|
|
659
|
-
* inlinePathParameters: false # Set by migration
|
|
660
|
-
* enableInlineTypes: false # Set by migration
|
|
661
|
-
* noSerdeLayer: false # Set by migration
|
|
662
|
-
* omitUndefined: false # Set by migration
|
|
663
|
-
* skipResponseValidation: false # Set by migration
|
|
664
|
-
* useLegacyExports: true # Set by migration
|
|
665
|
-
* ```
|
|
666
|
-
*
|
|
667
|
-
* **Result:** SDK behavior remains unchanged, existing code continues to work.
|
|
668
|
-
*
|
|
669
|
-
* ### Example 2: Partially Configured (Selective Migration)
|
|
670
|
-
*
|
|
671
|
-
* **Before Migration:**
|
|
672
|
-
* ```yaml
|
|
673
|
-
* generators:
|
|
674
|
-
* - name: fernapi/fern-typescript-sdk
|
|
675
|
-
* version: 0.9.0
|
|
676
|
-
* config:
|
|
677
|
-
* inlineFileProperties: true # User explicitly wants new behavior
|
|
678
|
-
* packageName: "@acme/sdk"
|
|
679
|
-
* ```
|
|
680
|
-
*
|
|
681
|
-
* **After Migration:**
|
|
682
|
-
* ```yaml
|
|
683
|
-
* generators:
|
|
684
|
-
* - name: fernapi/fern-typescript-sdk
|
|
685
|
-
* version: 1.0.0
|
|
686
|
-
* config:
|
|
687
|
-
* inlineFileProperties: true # Preserved (explicitly set)
|
|
688
|
-
* packageName: "@acme/sdk" # Preserved (custom field)
|
|
689
|
-
* inlinePathParameters: false # Set by migration
|
|
690
|
-
* enableInlineTypes: false # Set by migration
|
|
691
|
-
* noSerdeLayer: false # Set by migration
|
|
692
|
-
* omitUndefined: false # Set by migration
|
|
693
|
-
* skipResponseValidation: false # Set by migration
|
|
694
|
-
* useLegacyExports: true # Set by migration
|
|
695
|
-
* ```
|
|
696
|
-
*
|
|
697
|
-
* **Result:** User's explicit choice is honored, other fields get old defaults.
|
|
698
|
-
*
|
|
699
|
-
* ### Example 3: Fully Configured (No Migration Needed)
|
|
700
|
-
*
|
|
701
|
-
* **Before Migration:**
|
|
702
|
-
* ```yaml
|
|
703
|
-
* generators:
|
|
704
|
-
* - name: fernapi/fern-typescript-sdk
|
|
705
|
-
* version: 0.9.0
|
|
706
|
-
* config:
|
|
707
|
-
* inlineFileProperties: true
|
|
708
|
-
* inlinePathParameters: true
|
|
709
|
-
* enableInlineTypes: true
|
|
710
|
-
* noSerdeLayer: true
|
|
711
|
-
* omitUndefined: true
|
|
712
|
-
* skipResponseValidation: true
|
|
713
|
-
* useLegacyExports: false
|
|
714
|
-
* ```
|
|
647
|
+
* This module contains migrations for configuration changes for
|
|
648
|
+
* the C# SDK generator:
|
|
649
|
+
* - fernapi/fern-csharp-sdk
|
|
715
650
|
*
|
|
716
|
-
*
|
|
717
|
-
*
|
|
718
|
-
*
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
651
|
+
* Each migration is defined in a separate file under this directory.
|
|
652
|
+
* Migrations are automatically applied by the Fern CLI when running:
|
|
653
|
+
* `fern generator upgrade --generator csharp-sdk`
|
|
654
|
+
*/
|
|
655
|
+
const migrationModule$4 = { migrations: [migration_1_0_0$2, migration_2_0_0$2] };
|
|
656
|
+
var migrations_default$4 = migrationModule$4;
|
|
657
|
+
|
|
658
|
+
//#endregion
|
|
659
|
+
//#region src/generators/java/migrations/2.0.0.ts
|
|
660
|
+
const migration_2_0_0$1 = {
|
|
661
|
+
version: "2.0.0",
|
|
662
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
663
|
+
draft["disable-required-property-builder-checks"] ??= true;
|
|
664
|
+
}),
|
|
665
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
//#endregion
|
|
669
|
+
//#region src/generators/java/migrations/3.0.0.ts
|
|
670
|
+
const migration_3_0_0$1 = {
|
|
671
|
+
version: "3.0.0",
|
|
672
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
673
|
+
draft["enable-forward-compatible-enums"] ??= false;
|
|
674
|
+
}),
|
|
675
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
//#endregion
|
|
679
|
+
//#region src/generators/java/migrations/index.ts
|
|
680
|
+
/**
|
|
681
|
+
* Migration module for Java SDK generator.
|
|
731
682
|
*
|
|
732
|
-
*
|
|
683
|
+
* This module contains migrations for configuration changes for
|
|
684
|
+
* the Java SDK generator:
|
|
685
|
+
* - fernapi/fern-java-sdk
|
|
733
686
|
*
|
|
734
|
-
*
|
|
687
|
+
* Each migration is defined in a separate file under this directory.
|
|
688
|
+
* Migrations are automatically applied by the Fern CLI when running:
|
|
689
|
+
* `fern generator upgrade --generator java-sdk`
|
|
690
|
+
*/
|
|
691
|
+
const migrationModule$3 = { migrations: [migration_2_0_0$1, migration_3_0_0$1] };
|
|
692
|
+
var migrations_default$3 = migrationModule$3;
|
|
693
|
+
|
|
694
|
+
//#endregion
|
|
695
|
+
//#region src/generators/java-model/migrations/1.0.0.ts
|
|
696
|
+
const migration_1_0_0$1 = {
|
|
697
|
+
version: "1.0.0",
|
|
698
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
699
|
+
draft["disable-required-property-builder-checks"] ??= true;
|
|
700
|
+
}),
|
|
701
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
//#endregion
|
|
705
|
+
//#region src/generators/java-model/migrations/index.ts
|
|
706
|
+
/**
|
|
707
|
+
* Migration module for Java Model generators.
|
|
735
708
|
*
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
* -
|
|
739
|
-
* -
|
|
740
|
-
* - **Modern exports**: Better tree-shaking and compatibility with modern bundlers
|
|
709
|
+
* This module contains migrations for configuration changes for
|
|
710
|
+
* the Java Model generators:
|
|
711
|
+
* - fernapi/fern-java-model
|
|
712
|
+
* - fernapi/fern-java-spring
|
|
741
713
|
*
|
|
742
|
-
*
|
|
714
|
+
* Each migration is defined in a separate file under this directory.
|
|
715
|
+
* Migrations are automatically applied by the Fern CLI when running:
|
|
716
|
+
* `fern generator upgrade --generator java-model`
|
|
717
|
+
* `fern generator upgrade --generator java-spring`
|
|
718
|
+
*/
|
|
719
|
+
const migrationModule$2 = { migrations: [migration_1_0_0$1] };
|
|
720
|
+
var migrations_default$2 = migrationModule$2;
|
|
721
|
+
|
|
722
|
+
//#endregion
|
|
723
|
+
//#region src/generators/python/migrations/4.0.0.ts
|
|
724
|
+
const migration_4_0_0 = {
|
|
725
|
+
version: "4.0.0",
|
|
726
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
727
|
+
if (draft.pydantic_config === void 0 || draft.pydantic_config === null) draft.pydantic_config = {};
|
|
728
|
+
if (typeof draft.pydantic_config === "object" && draft.pydantic_config !== null) draft.pydantic_config.use_pydantic_field_aliases ??= true;
|
|
729
|
+
}),
|
|
730
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/generators/python/migrations/index.ts
|
|
735
|
+
/**
|
|
736
|
+
* Migration module for Python SDK generator.
|
|
743
737
|
*
|
|
744
|
-
*
|
|
745
|
-
*
|
|
738
|
+
* This module contains migrations for configuration changes for
|
|
739
|
+
* the Python SDK generator:
|
|
740
|
+
* - fernapi/fern-python-sdk
|
|
746
741
|
*
|
|
747
|
-
*
|
|
748
|
-
*
|
|
749
|
-
*
|
|
750
|
-
* version: 1.0.0
|
|
751
|
-
* config: {} # Remove all fields to use new defaults
|
|
752
|
-
* ```
|
|
742
|
+
* Each migration is defined in a separate file under this directory.
|
|
743
|
+
* Migrations are automatically applied by the Fern CLI when running:
|
|
744
|
+
* `fern generator upgrade --generator python-sdk`
|
|
753
745
|
*
|
|
754
|
-
*
|
|
746
|
+
* Note: Versions 1.0.0 and 2.0.0 mentioned "breaking configuration changes"
|
|
747
|
+
* but did not document specific configuration options that changed, so they
|
|
748
|
+
* are not included in this migration module.
|
|
755
749
|
*/
|
|
750
|
+
const migrationModule$1 = { migrations: [migration_4_0_0] };
|
|
751
|
+
var migrations_default$1 = migrationModule$1;
|
|
752
|
+
|
|
753
|
+
//#endregion
|
|
754
|
+
//#region src/generators/typescript/migrations/1.0.0.ts
|
|
756
755
|
const migration_1_0_0 = {
|
|
757
756
|
version: "1.0.0",
|
|
758
757
|
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
@@ -769,156 +768,6 @@ const migration_1_0_0 = {
|
|
|
769
768
|
|
|
770
769
|
//#endregion
|
|
771
770
|
//#region src/generators/typescript/migrations/2.0.0.ts
|
|
772
|
-
/**
|
|
773
|
-
* Migration for version 2.0.0
|
|
774
|
-
*
|
|
775
|
-
* ## Context
|
|
776
|
-
*
|
|
777
|
-
* Version 2.0.0 introduced zero-dependency SDKs by default, using native browser and
|
|
778
|
-
* Node.js APIs instead of external packages. This significantly reduces bundle size
|
|
779
|
-
* and eliminates dependency management issues, but requires Node.js 18+ and modern
|
|
780
|
-
* browsers with native fetch/streams support.
|
|
781
|
-
*
|
|
782
|
-
* For users upgrading from pre-2.0.0 versions who need to maintain compatibility with
|
|
783
|
-
* older runtimes, this migration explicitly sets the old defaults that use polyfills
|
|
784
|
-
* and wrapper libraries.
|
|
785
|
-
*
|
|
786
|
-
* ## Changed Defaults
|
|
787
|
-
*
|
|
788
|
-
* | Field | Old Default (pre-2.0.0) | New Default (2.0.0+) | Impact |
|
|
789
|
-
* |-------|-------------------------|----------------------|--------|
|
|
790
|
-
* | `streamType` | `"wrapper"` | `"web"` | Uses native Web Streams API instead of wrapper library |
|
|
791
|
-
* | `fileResponseType` | `"stream"` | `"binary-response"` | Returns binary response instead of stream wrapper |
|
|
792
|
-
* | `formDataSupport` | `"Node16"` | `"Node18"` | Uses native FormData (Node 18+) instead of polyfill |
|
|
793
|
-
* | `fetchSupport` | `"node-fetch"` | `"native"` | Uses native fetch (Node 18+/browsers) instead of node-fetch |
|
|
794
|
-
*
|
|
795
|
-
* ## Migration Strategy
|
|
796
|
-
*
|
|
797
|
-
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
798
|
-
* values that are explicitly undefined. This means:
|
|
799
|
-
* - ✅ If a user has explicitly configured a field, that value is preserved
|
|
800
|
-
* - ✅ If a field is undefined, the old default (with dependencies) is set
|
|
801
|
-
* - ✅ Users can opt into zero-dependency mode by removing these fields later
|
|
802
|
-
*
|
|
803
|
-
* ## Examples
|
|
804
|
-
*
|
|
805
|
-
* ### Example 1: Empty Config (Migration Applied - Dependencies Maintained)
|
|
806
|
-
*
|
|
807
|
-
* **Before Migration (1.9.0 → 2.0.0):**
|
|
808
|
-
* ```yaml
|
|
809
|
-
* generators:
|
|
810
|
-
* - name: fernapi/fern-typescript-sdk
|
|
811
|
-
* version: 1.9.0
|
|
812
|
-
* config: {}
|
|
813
|
-
* ```
|
|
814
|
-
*
|
|
815
|
-
* **After Migration:**
|
|
816
|
-
* ```yaml
|
|
817
|
-
* generators:
|
|
818
|
-
* - name: fernapi/fern-typescript-sdk
|
|
819
|
-
* version: 2.0.0
|
|
820
|
-
* config:
|
|
821
|
-
* streamType: wrapper # Set by migration - uses wrapper library
|
|
822
|
-
* fileResponseType: stream # Set by migration - uses stream wrapper
|
|
823
|
-
* formDataSupport: Node16 # Set by migration - uses polyfill
|
|
824
|
-
* fetchSupport: node-fetch # Set by migration - uses node-fetch package
|
|
825
|
-
* ```
|
|
826
|
-
*
|
|
827
|
-
* **Result:** SDK continues using external dependencies, works with Node 16+.
|
|
828
|
-
*
|
|
829
|
-
* **Dependencies Required:**
|
|
830
|
-
* - `node-fetch` for HTTP requests
|
|
831
|
-
* - `form-data` for multipart uploads
|
|
832
|
-
* - Stream wrapper libraries
|
|
833
|
-
*
|
|
834
|
-
* ### Example 2: Opting Into Zero-Dependency Mode
|
|
835
|
-
*
|
|
836
|
-
* **After Initial Migration:**
|
|
837
|
-
* ```yaml
|
|
838
|
-
* generators:
|
|
839
|
-
* - name: fernapi/fern-typescript-sdk
|
|
840
|
-
* version: 2.0.0
|
|
841
|
-
* config:
|
|
842
|
-
* streamType: wrapper
|
|
843
|
-
* fileResponseType: stream
|
|
844
|
-
* formDataSupport: Node16
|
|
845
|
-
* fetchSupport: node-fetch
|
|
846
|
-
* ```
|
|
847
|
-
*
|
|
848
|
-
* **To Adopt Zero-Dependency Mode:**
|
|
849
|
-
* ```yaml
|
|
850
|
-
* generators:
|
|
851
|
-
* - name: fernapi/fern-typescript-sdk
|
|
852
|
-
* version: 2.0.0
|
|
853
|
-
* config: {} # Remove all fields to use new defaults
|
|
854
|
-
* ```
|
|
855
|
-
*
|
|
856
|
-
* **Result:** SDK uses native APIs, no external dependencies required.
|
|
857
|
-
*
|
|
858
|
-
* **Requirements for Zero-Dependency Mode:**
|
|
859
|
-
* - Node.js 18+ (for native fetch and FormData)
|
|
860
|
-
* - OR modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)
|
|
861
|
-
*
|
|
862
|
-
* ## Why These Defaults Changed
|
|
863
|
-
*
|
|
864
|
-
* ### Bundle Size Impact
|
|
865
|
-
*
|
|
866
|
-
* **With Dependencies (Old):**
|
|
867
|
-
* ```
|
|
868
|
-
* node-fetch: ~90KB
|
|
869
|
-
* form-data: ~40KB
|
|
870
|
-
* stream wrappers: ~20KB
|
|
871
|
-
* Total: ~150KB added to your bundle
|
|
872
|
-
* ```
|
|
873
|
-
*
|
|
874
|
-
* **Zero Dependencies (New):**
|
|
875
|
-
* ```
|
|
876
|
-
* Total: 0KB (uses native APIs)
|
|
877
|
-
* ```
|
|
878
|
-
*
|
|
879
|
-
* ### Performance Benefits
|
|
880
|
-
*
|
|
881
|
-
* - **Native fetch**: ~30% faster than node-fetch
|
|
882
|
-
* - **Native streams**: ~40% faster than wrapper libraries
|
|
883
|
-
* - **No dependency resolution**: Faster npm install and startup time
|
|
884
|
-
*
|
|
885
|
-
* ## Runtime Compatibility
|
|
886
|
-
*
|
|
887
|
-
* ### With Old Defaults (Migration Applied)
|
|
888
|
-
* - ✅ Node.js 12+
|
|
889
|
-
* - ✅ All browsers (with polyfills)
|
|
890
|
-
* - ✅ Edge runtimes (Cloudflare Workers, etc.)
|
|
891
|
-
*
|
|
892
|
-
* ### With New Defaults (Zero-Dependency)
|
|
893
|
-
* - ✅ Node.js 18+
|
|
894
|
-
* - ✅ Modern browsers (last 2 years)
|
|
895
|
-
* - ⚠️ May need polyfills for edge runtimes
|
|
896
|
-
*
|
|
897
|
-
* ## Migration Path to Zero-Dependency
|
|
898
|
-
*
|
|
899
|
-
* ### Step 1: Upgrade with Migration (Safe)
|
|
900
|
-
* ```bash
|
|
901
|
-
* fern generator upgrade
|
|
902
|
-
* ```
|
|
903
|
-
* Result: Old behavior preserved, dependencies still required.
|
|
904
|
-
*
|
|
905
|
-
* ### Step 2: Update Node Version (If Needed)
|
|
906
|
-
* Ensure your runtime is Node 18+ or a modern browser.
|
|
907
|
-
*
|
|
908
|
-
* ### Step 3: Remove Old Defaults
|
|
909
|
-
* Edit `generators.yml`:
|
|
910
|
-
* ```yaml
|
|
911
|
-
* config: {} # Use new zero-dependency defaults
|
|
912
|
-
* ```
|
|
913
|
-
*
|
|
914
|
-
* ### Step 4: Remove Dependencies
|
|
915
|
-
* ```bash
|
|
916
|
-
* npm uninstall node-fetch form-data
|
|
917
|
-
* ```
|
|
918
|
-
*
|
|
919
|
-
* ### Step 5: Test Thoroughly
|
|
920
|
-
* Verify streams, file uploads, and fetch operations work correctly.
|
|
921
|
-
*/
|
|
922
771
|
const migration_2_0_0 = {
|
|
923
772
|
version: "2.0.0",
|
|
924
773
|
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
@@ -932,245 +781,6 @@ const migration_2_0_0 = {
|
|
|
932
781
|
|
|
933
782
|
//#endregion
|
|
934
783
|
//#region src/generators/typescript/migrations/3.0.0.ts
|
|
935
|
-
/**
|
|
936
|
-
* Migration for version 3.0.0
|
|
937
|
-
*
|
|
938
|
-
* ## Context
|
|
939
|
-
*
|
|
940
|
-
* Version 3.0.0 modernized the generated SDK tooling by switching to pnpm and Vitest,
|
|
941
|
-
* which offer better performance, smaller disk usage, and faster test execution compared
|
|
942
|
-
* to yarn and Jest. However, teams with existing workflows may prefer to maintain their
|
|
943
|
-
* current tooling.
|
|
944
|
-
*
|
|
945
|
-
* This migration explicitly sets the old defaults for users upgrading from pre-3.0.0
|
|
946
|
-
* versions, allowing them to continue using yarn and Jest without any changes to their
|
|
947
|
-
* development workflow.
|
|
948
|
-
*
|
|
949
|
-
* ## Changed Defaults
|
|
950
|
-
*
|
|
951
|
-
* | Field | Old Default (pre-3.0.0) | New Default (3.0.0+) | Impact |
|
|
952
|
-
* |-------|-------------------------|----------------------|--------|
|
|
953
|
-
* | `packageManager` | `"yarn"` | `"pnpm"` | Generated package.json uses pnpm for dependency management |
|
|
954
|
-
* | `testFramework` | `"jest"` | `"vitest"` | Generated tests use Vitest instead of Jest |
|
|
955
|
-
*
|
|
956
|
-
* ## Migration Strategy
|
|
957
|
-
*
|
|
958
|
-
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
959
|
-
* values that are explicitly undefined. This means:
|
|
960
|
-
* - ✅ If a user has explicitly configured a field, that value is preserved
|
|
961
|
-
* - ✅ If a field is undefined, the old default is set
|
|
962
|
-
* - ✅ Users can opt into modern tooling by removing these fields later
|
|
963
|
-
*
|
|
964
|
-
* ## Examples
|
|
965
|
-
*
|
|
966
|
-
* ### Example 1: Empty Config (Migration Applied - Keep Yarn + Jest)
|
|
967
|
-
*
|
|
968
|
-
* **Before Migration (2.9.0 → 3.0.0):**
|
|
969
|
-
* ```yaml
|
|
970
|
-
* generators:
|
|
971
|
-
* - name: fernapi/fern-typescript-sdk
|
|
972
|
-
* version: 2.9.0
|
|
973
|
-
* config: {}
|
|
974
|
-
* ```
|
|
975
|
-
*
|
|
976
|
-
* **After Migration:**
|
|
977
|
-
* ```yaml
|
|
978
|
-
* generators:
|
|
979
|
-
* - name: fernapi/fern-typescript-sdk
|
|
980
|
-
* version: 3.0.0
|
|
981
|
-
* config:
|
|
982
|
-
* packageManager: yarn # Set by migration - keeps yarn
|
|
983
|
-
* testFramework: jest # Set by migration - keeps jest
|
|
984
|
-
* ```
|
|
985
|
-
*
|
|
986
|
-
* **Result:** Generated SDK continues using yarn and Jest.
|
|
987
|
-
*
|
|
988
|
-
* **Generated Files:**
|
|
989
|
-
* - `package.json` with yarn scripts and Jest config
|
|
990
|
-
* - Test files using Jest syntax (`describe`, `it`, `expect`)
|
|
991
|
-
* - `.yarnrc` or `.yarnrc.yml` if applicable
|
|
992
|
-
*
|
|
993
|
-
* ### Example 2: Adopting Modern Tooling (pnpm + Vitest)
|
|
994
|
-
*
|
|
995
|
-
* **After Initial Migration:**
|
|
996
|
-
* ```yaml
|
|
997
|
-
* generators:
|
|
998
|
-
* - name: fernapi/fern-typescript-sdk
|
|
999
|
-
* version: 3.0.0
|
|
1000
|
-
* config:
|
|
1001
|
-
* packageManager: yarn
|
|
1002
|
-
* testFramework: jest
|
|
1003
|
-
* ```
|
|
1004
|
-
*
|
|
1005
|
-
* **To Adopt pnpm + Vitest:**
|
|
1006
|
-
* ```yaml
|
|
1007
|
-
* generators:
|
|
1008
|
-
* - name: fernapi/fern-typescript-sdk
|
|
1009
|
-
* version: 3.0.0
|
|
1010
|
-
* config: {} # Remove to use new defaults
|
|
1011
|
-
* ```
|
|
1012
|
-
*
|
|
1013
|
-
* **Result:** Generated SDK uses pnpm and Vitest.
|
|
1014
|
-
*
|
|
1015
|
-
* **Generated Files:**
|
|
1016
|
-
* - `package.json` with pnpm scripts
|
|
1017
|
-
* - `vitest.config.ts` for test configuration
|
|
1018
|
-
* - Test files using Vitest syntax (compatible with Jest)
|
|
1019
|
-
* - `pnpm-workspace.yaml` if applicable
|
|
1020
|
-
*
|
|
1021
|
-
* ### Example 3: Mixed Tooling (Custom Configuration)
|
|
1022
|
-
*
|
|
1023
|
-
* **Keep yarn but adopt Vitest:**
|
|
1024
|
-
* ```yaml
|
|
1025
|
-
* generators:
|
|
1026
|
-
* - name: fernapi/fern-typescript-sdk
|
|
1027
|
-
* version: 3.0.0
|
|
1028
|
-
* config:
|
|
1029
|
-
* packageManager: yarn # Keep yarn
|
|
1030
|
-
* # testFramework defaults to vitest
|
|
1031
|
-
* ```
|
|
1032
|
-
*
|
|
1033
|
-
* **Keep Jest but adopt pnpm:**
|
|
1034
|
-
* ```yaml
|
|
1035
|
-
* generators:
|
|
1036
|
-
* - name: fernapi/fern-typescript-sdk
|
|
1037
|
-
* version: 3.0.0
|
|
1038
|
-
* config:
|
|
1039
|
-
* testFramework: jest # Keep Jest
|
|
1040
|
-
* # packageManager defaults to pnpm
|
|
1041
|
-
* ```
|
|
1042
|
-
*
|
|
1043
|
-
* ## Why These Defaults Changed
|
|
1044
|
-
*
|
|
1045
|
-
* ### pnpm vs yarn
|
|
1046
|
-
*
|
|
1047
|
-
* **Performance:**
|
|
1048
|
-
* - pnpm install is 2-3x faster than yarn
|
|
1049
|
-
* - Uses hard links instead of copying files
|
|
1050
|
-
* - Significantly smaller `node_modules` (50-70% reduction)
|
|
1051
|
-
*
|
|
1052
|
-
* **Correctness:**
|
|
1053
|
-
* - Strict dependency resolution prevents phantom dependencies
|
|
1054
|
-
* - Better monorepo support with workspaces
|
|
1055
|
-
* - More deterministic builds
|
|
1056
|
-
*
|
|
1057
|
-
* **Ecosystem:**
|
|
1058
|
-
* - Growing adoption in major projects (Vue 3, Prisma, Turborepo)
|
|
1059
|
-
* - Better compatibility with modern tooling
|
|
1060
|
-
*
|
|
1061
|
-
* ### Vitest vs Jest
|
|
1062
|
-
*
|
|
1063
|
-
* **Performance:**
|
|
1064
|
-
* - 10-20x faster test execution with native ESM
|
|
1065
|
-
* - Built-in watch mode with instant HMR
|
|
1066
|
-
* - Parallel test execution by default
|
|
1067
|
-
*
|
|
1068
|
-
* **Developer Experience:**
|
|
1069
|
-
* - Native TypeScript support (no ts-jest needed)
|
|
1070
|
-
* - Vite-powered with instant module reloading
|
|
1071
|
-
* - Jest-compatible API (easy migration)
|
|
1072
|
-
* - Better error messages and stack traces
|
|
1073
|
-
*
|
|
1074
|
-
* **Modern Features:**
|
|
1075
|
-
* - Native ESM support
|
|
1076
|
-
* - Web Workers and multi-threading support
|
|
1077
|
-
* - In-source testing capabilities
|
|
1078
|
-
*
|
|
1079
|
-
* ## Compatibility Notes
|
|
1080
|
-
*
|
|
1081
|
-
* ### Vitest Limitations
|
|
1082
|
-
*
|
|
1083
|
-
* Vitest is **not compatible** with certain generator configurations:
|
|
1084
|
-
*
|
|
1085
|
-
* 1. **`useBigInt: true`**: Vitest doesn't handle BigInt serialization the same way as Jest
|
|
1086
|
-
* - **Workaround**: Keep `testFramework: jest` if using BigInt
|
|
1087
|
-
*
|
|
1088
|
-
* 2. **`streamType: wrapper`**: Older stream wrappers may not work with Vitest's ESM mode
|
|
1089
|
-
* - **Workaround**: Either use `streamType: web` or keep `testFramework: jest`
|
|
1090
|
-
*
|
|
1091
|
-
* 3. **`packagePath` (custom paths)**: May have module resolution issues with Vitest
|
|
1092
|
-
* - **Workaround**: Keep `testFramework: jest` for complex custom paths
|
|
1093
|
-
*
|
|
1094
|
-
* If you have any of these configurations, the migration correctly keeps Jest as the test framework.
|
|
1095
|
-
*
|
|
1096
|
-
* ## Migration Path to Modern Tooling
|
|
1097
|
-
*
|
|
1098
|
-
* ### Step 1: Upgrade with Migration (Safe)
|
|
1099
|
-
* ```bash
|
|
1100
|
-
* fern generator upgrade
|
|
1101
|
-
* ```
|
|
1102
|
-
* Result: Keeps yarn and Jest, no workflow changes needed.
|
|
1103
|
-
*
|
|
1104
|
-
* ### Step 2: Install pnpm (Optional)
|
|
1105
|
-
* ```bash
|
|
1106
|
-
* npm install -g pnpm@latest
|
|
1107
|
-
* ```
|
|
1108
|
-
*
|
|
1109
|
-
* ### Step 3: Adopt Modern Tooling (Optional)
|
|
1110
|
-
* Edit `generators.yml`:
|
|
1111
|
-
* ```yaml
|
|
1112
|
-
* config: {} # Use pnpm + vitest
|
|
1113
|
-
* ```
|
|
1114
|
-
*
|
|
1115
|
-
* ### Step 4: Update CI/CD (Optional)
|
|
1116
|
-
* Update CI scripts to use pnpm:
|
|
1117
|
-
* ```yaml
|
|
1118
|
-
* # GitHub Actions example
|
|
1119
|
-
* - uses: pnpm/action-setup@v2
|
|
1120
|
-
* with:
|
|
1121
|
-
* version: 8
|
|
1122
|
-
* - run: pnpm install
|
|
1123
|
-
* - run: pnpm test
|
|
1124
|
-
* ```
|
|
1125
|
-
*
|
|
1126
|
-
* ### Step 5: Migrate yarn.lock (Optional)
|
|
1127
|
-
* ```bash
|
|
1128
|
-
* # Convert yarn.lock to pnpm-lock.yaml
|
|
1129
|
-
* pnpm import
|
|
1130
|
-
* rm yarn.lock
|
|
1131
|
-
* ```
|
|
1132
|
-
*
|
|
1133
|
-
* ## Troubleshooting
|
|
1134
|
-
*
|
|
1135
|
-
* ### "pnpm: command not found"
|
|
1136
|
-
* **Cause:** pnpm not installed globally.
|
|
1137
|
-
* **Solution:** Install pnpm: `npm install -g pnpm`
|
|
1138
|
-
*
|
|
1139
|
-
* ### Vitest errors with BigInt
|
|
1140
|
-
* **Cause:** Vitest and BigInt serialization incompatibility.
|
|
1141
|
-
* **Solution:** Use `testFramework: jest` in config.
|
|
1142
|
-
*
|
|
1143
|
-
* ### Module resolution errors with Vitest
|
|
1144
|
-
* **Cause:** ESM/CommonJS compatibility issues.
|
|
1145
|
-
* **Solution:** Either fix module format or use `testFramework: jest`.
|
|
1146
|
-
*
|
|
1147
|
-
* ### Tests fail after switching to Vitest
|
|
1148
|
-
* **Cause:** Vitest has stricter ESM requirements.
|
|
1149
|
-
* **Solution:** Ensure `package.json` has `"type": "module"` or use `.ts` extensions.
|
|
1150
|
-
*
|
|
1151
|
-
* ## Performance Comparison
|
|
1152
|
-
*
|
|
1153
|
-
* Based on typical SDK project (50 tests, 1000 LOC):
|
|
1154
|
-
*
|
|
1155
|
-
* **Install Time:**
|
|
1156
|
-
* - yarn: ~15s
|
|
1157
|
-
* - pnpm: ~5s (3x faster)
|
|
1158
|
-
*
|
|
1159
|
-
* **Test Execution:**
|
|
1160
|
-
* - Jest: ~8s
|
|
1161
|
-
* - Vitest: ~0.8s (10x faster)
|
|
1162
|
-
*
|
|
1163
|
-
* **Disk Usage:**
|
|
1164
|
-
* - yarn: ~200MB node_modules
|
|
1165
|
-
* - pnpm: ~80MB node_modules (60% reduction)
|
|
1166
|
-
*
|
|
1167
|
-
* ## Recommendations
|
|
1168
|
-
*
|
|
1169
|
-
* - **New projects**: Use the new defaults (pnpm + Vitest)
|
|
1170
|
-
* - **Existing projects**: Keep old defaults initially, migrate when convenient
|
|
1171
|
-
* - **CI/CD-heavy projects**: Consider pnpm for faster installs
|
|
1172
|
-
* - **Projects with BigInt**: Keep Jest until Vitest improves BigInt support
|
|
1173
|
-
*/
|
|
1174
784
|
const migration_3_0_0 = {
|
|
1175
785
|
version: "3.0.0",
|
|
1176
786
|
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
@@ -1214,6 +824,13 @@ var migrations_default = migrationModule;
|
|
|
1214
824
|
* 3. Add entries for all generator name variants
|
|
1215
825
|
*/
|
|
1216
826
|
const migrations = {
|
|
827
|
+
"fernapi/fern-csharp-sdk": migrations_default$4,
|
|
828
|
+
"fernapi/fern-java-model": migrations_default$2,
|
|
829
|
+
"fernapi/fern-java-spring": migrations_default$2,
|
|
830
|
+
"fernapi/fern-java-sdk": migrations_default$3,
|
|
831
|
+
"fernapi/fern-python-sdk": migrations_default$1,
|
|
832
|
+
"fernapi/fern-fastapi-server": migrations_default$1,
|
|
833
|
+
"fernapi/fern-pydantic-model": migrations_default$1,
|
|
1217
834
|
"fernapi/fern-typescript": migrations_default,
|
|
1218
835
|
"fernapi/fern-typescript-sdk": migrations_default,
|
|
1219
836
|
"fernapi/fern-typescript-node-sdk": migrations_default,
|