@fern-api/generator-migrations 0.0.1
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/README.md +352 -0
- package/lib/generators/typescript/migrations/1.0.0.d.ts +152 -0
- package/lib/generators/typescript/migrations/1.0.0.d.ts.map +1 -0
- package/lib/generators/typescript/migrations/1.0.0.js +166 -0
- package/lib/generators/typescript/migrations/1.0.0.js.map +1 -0
- package/lib/generators/typescript/migrations/2.0.0.d.ts +153 -0
- package/lib/generators/typescript/migrations/2.0.0.d.ts.map +1 -0
- package/lib/generators/typescript/migrations/2.0.0.js +163 -0
- package/lib/generators/typescript/migrations/2.0.0.js.map +1 -0
- package/lib/generators/typescript/migrations/3.0.0.d.ts +242 -0
- package/lib/generators/typescript/migrations/3.0.0.d.ts.map +1 -0
- package/lib/generators/typescript/migrations/3.0.0.js +250 -0
- package/lib/generators/typescript/migrations/3.0.0.js.map +1 -0
- package/lib/generators/typescript/migrations/index.d.ts +18 -0
- package/lib/generators/typescript/migrations/index.d.ts.map +1 -0
- package/lib/generators/typescript/migrations/index.js +22 -0
- package/lib/generators/typescript/migrations/index.js.map +1 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { Migration } from "@fern-api/migrations-base";
|
|
2
|
+
/**
|
|
3
|
+
* Migration for version 2.0.0
|
|
4
|
+
*
|
|
5
|
+
* ## Context
|
|
6
|
+
*
|
|
7
|
+
* Version 2.0.0 introduced zero-dependency SDKs by default, using native browser and
|
|
8
|
+
* Node.js APIs instead of external packages. This significantly reduces bundle size
|
|
9
|
+
* and eliminates dependency management issues, but requires Node.js 18+ and modern
|
|
10
|
+
* browsers with native fetch/streams support.
|
|
11
|
+
*
|
|
12
|
+
* For users upgrading from pre-2.0.0 versions who need to maintain compatibility with
|
|
13
|
+
* older runtimes, this migration explicitly sets the old defaults that use polyfills
|
|
14
|
+
* and wrapper libraries.
|
|
15
|
+
*
|
|
16
|
+
* ## Changed Defaults
|
|
17
|
+
*
|
|
18
|
+
* | Field | Old Default (pre-2.0.0) | New Default (2.0.0+) | Impact |
|
|
19
|
+
* |-------|-------------------------|----------------------|--------|
|
|
20
|
+
* | `streamType` | `"wrapper"` | `"web"` | Uses native Web Streams API instead of wrapper library |
|
|
21
|
+
* | `fileResponseType` | `"stream"` | `"binary-response"` | Returns binary response instead of stream wrapper |
|
|
22
|
+
* | `formDataSupport` | `"Node16"` | `"Node18"` | Uses native FormData (Node 18+) instead of polyfill |
|
|
23
|
+
* | `fetchSupport` | `"node-fetch"` | `"native"` | Uses native fetch (Node 18+/browsers) instead of node-fetch |
|
|
24
|
+
*
|
|
25
|
+
* ## Migration Strategy
|
|
26
|
+
*
|
|
27
|
+
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
28
|
+
* values that are explicitly undefined. This means:
|
|
29
|
+
* - ✅ If a user has explicitly configured a field, that value is preserved
|
|
30
|
+
* - ✅ If a field is undefined, the old default (with dependencies) is set
|
|
31
|
+
* - ✅ Users can opt into zero-dependency mode by removing these fields later
|
|
32
|
+
*
|
|
33
|
+
* ## Examples
|
|
34
|
+
*
|
|
35
|
+
* ### Example 1: Empty Config (Migration Applied - Dependencies Maintained)
|
|
36
|
+
*
|
|
37
|
+
* **Before Migration (1.9.0 → 2.0.0):**
|
|
38
|
+
* ```yaml
|
|
39
|
+
* generators:
|
|
40
|
+
* - name: fernapi/fern-typescript-sdk
|
|
41
|
+
* version: 1.9.0
|
|
42
|
+
* config: {}
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* **After Migration:**
|
|
46
|
+
* ```yaml
|
|
47
|
+
* generators:
|
|
48
|
+
* - name: fernapi/fern-typescript-sdk
|
|
49
|
+
* version: 2.0.0
|
|
50
|
+
* config:
|
|
51
|
+
* streamType: wrapper # Set by migration - uses wrapper library
|
|
52
|
+
* fileResponseType: stream # Set by migration - uses stream wrapper
|
|
53
|
+
* formDataSupport: Node16 # Set by migration - uses polyfill
|
|
54
|
+
* fetchSupport: node-fetch # Set by migration - uses node-fetch package
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* **Result:** SDK continues using external dependencies, works with Node 16+.
|
|
58
|
+
*
|
|
59
|
+
* **Dependencies Required:**
|
|
60
|
+
* - `node-fetch` for HTTP requests
|
|
61
|
+
* - `form-data` for multipart uploads
|
|
62
|
+
* - Stream wrapper libraries
|
|
63
|
+
*
|
|
64
|
+
* ### Example 2: Opting Into Zero-Dependency Mode
|
|
65
|
+
*
|
|
66
|
+
* **After Initial Migration:**
|
|
67
|
+
* ```yaml
|
|
68
|
+
* generators:
|
|
69
|
+
* - name: fernapi/fern-typescript-sdk
|
|
70
|
+
* version: 2.0.0
|
|
71
|
+
* config:
|
|
72
|
+
* streamType: wrapper
|
|
73
|
+
* fileResponseType: stream
|
|
74
|
+
* formDataSupport: Node16
|
|
75
|
+
* fetchSupport: node-fetch
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* **To Adopt Zero-Dependency Mode:**
|
|
79
|
+
* ```yaml
|
|
80
|
+
* generators:
|
|
81
|
+
* - name: fernapi/fern-typescript-sdk
|
|
82
|
+
* version: 2.0.0
|
|
83
|
+
* config: {} # Remove all fields to use new defaults
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* **Result:** SDK uses native APIs, no external dependencies required.
|
|
87
|
+
*
|
|
88
|
+
* **Requirements for Zero-Dependency Mode:**
|
|
89
|
+
* - Node.js 18+ (for native fetch and FormData)
|
|
90
|
+
* - OR modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)
|
|
91
|
+
*
|
|
92
|
+
* ## Why These Defaults Changed
|
|
93
|
+
*
|
|
94
|
+
* ### Bundle Size Impact
|
|
95
|
+
*
|
|
96
|
+
* **With Dependencies (Old):**
|
|
97
|
+
* ```
|
|
98
|
+
* node-fetch: ~90KB
|
|
99
|
+
* form-data: ~40KB
|
|
100
|
+
* stream wrappers: ~20KB
|
|
101
|
+
* Total: ~150KB added to your bundle
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* **Zero Dependencies (New):**
|
|
105
|
+
* ```
|
|
106
|
+
* Total: 0KB (uses native APIs)
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* ### Performance Benefits
|
|
110
|
+
*
|
|
111
|
+
* - **Native fetch**: ~30% faster than node-fetch
|
|
112
|
+
* - **Native streams**: ~40% faster than wrapper libraries
|
|
113
|
+
* - **No dependency resolution**: Faster npm install and startup time
|
|
114
|
+
*
|
|
115
|
+
* ## Runtime Compatibility
|
|
116
|
+
*
|
|
117
|
+
* ### With Old Defaults (Migration Applied)
|
|
118
|
+
* - ✅ Node.js 12+
|
|
119
|
+
* - ✅ All browsers (with polyfills)
|
|
120
|
+
* - ✅ Edge runtimes (Cloudflare Workers, etc.)
|
|
121
|
+
*
|
|
122
|
+
* ### With New Defaults (Zero-Dependency)
|
|
123
|
+
* - ✅ Node.js 18+
|
|
124
|
+
* - ✅ Modern browsers (last 2 years)
|
|
125
|
+
* - ⚠️ May need polyfills for edge runtimes
|
|
126
|
+
*
|
|
127
|
+
* ## Migration Path to Zero-Dependency
|
|
128
|
+
*
|
|
129
|
+
* ### Step 1: Upgrade with Migration (Safe)
|
|
130
|
+
* ```bash
|
|
131
|
+
* fern generator upgrade
|
|
132
|
+
* ```
|
|
133
|
+
* Result: Old behavior preserved, dependencies still required.
|
|
134
|
+
*
|
|
135
|
+
* ### Step 2: Update Node Version (If Needed)
|
|
136
|
+
* Ensure your runtime is Node 18+ or a modern browser.
|
|
137
|
+
*
|
|
138
|
+
* ### Step 3: Remove Old Defaults
|
|
139
|
+
* Edit `generators.yml`:
|
|
140
|
+
* ```yaml
|
|
141
|
+
* config: {} # Use new zero-dependency defaults
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* ### Step 4: Remove Dependencies
|
|
145
|
+
* ```bash
|
|
146
|
+
* npm uninstall node-fetch form-data
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* ### Step 5: Test Thoroughly
|
|
150
|
+
* Verify streams, file uploads, and fetch operations work correctly.
|
|
151
|
+
*/
|
|
152
|
+
export declare const migration_2_0_0: Migration;
|
|
153
|
+
//# sourceMappingURL=2.0.0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2.0.0.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/2.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqJG;AACH,eAAO,MAAM,eAAe,EAAE,SAa7B,CAAC"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { migrateConfig } from "@fern-api/migrations-base";
|
|
2
|
+
/**
|
|
3
|
+
* Migration for version 2.0.0
|
|
4
|
+
*
|
|
5
|
+
* ## Context
|
|
6
|
+
*
|
|
7
|
+
* Version 2.0.0 introduced zero-dependency SDKs by default, using native browser and
|
|
8
|
+
* Node.js APIs instead of external packages. This significantly reduces bundle size
|
|
9
|
+
* and eliminates dependency management issues, but requires Node.js 18+ and modern
|
|
10
|
+
* browsers with native fetch/streams support.
|
|
11
|
+
*
|
|
12
|
+
* For users upgrading from pre-2.0.0 versions who need to maintain compatibility with
|
|
13
|
+
* older runtimes, this migration explicitly sets the old defaults that use polyfills
|
|
14
|
+
* and wrapper libraries.
|
|
15
|
+
*
|
|
16
|
+
* ## Changed Defaults
|
|
17
|
+
*
|
|
18
|
+
* | Field | Old Default (pre-2.0.0) | New Default (2.0.0+) | Impact |
|
|
19
|
+
* |-------|-------------------------|----------------------|--------|
|
|
20
|
+
* | `streamType` | `"wrapper"` | `"web"` | Uses native Web Streams API instead of wrapper library |
|
|
21
|
+
* | `fileResponseType` | `"stream"` | `"binary-response"` | Returns binary response instead of stream wrapper |
|
|
22
|
+
* | `formDataSupport` | `"Node16"` | `"Node18"` | Uses native FormData (Node 18+) instead of polyfill |
|
|
23
|
+
* | `fetchSupport` | `"node-fetch"` | `"native"` | Uses native fetch (Node 18+/browsers) instead of node-fetch |
|
|
24
|
+
*
|
|
25
|
+
* ## Migration Strategy
|
|
26
|
+
*
|
|
27
|
+
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
28
|
+
* values that are explicitly undefined. This means:
|
|
29
|
+
* - ✅ If a user has explicitly configured a field, that value is preserved
|
|
30
|
+
* - ✅ If a field is undefined, the old default (with dependencies) is set
|
|
31
|
+
* - ✅ Users can opt into zero-dependency mode by removing these fields later
|
|
32
|
+
*
|
|
33
|
+
* ## Examples
|
|
34
|
+
*
|
|
35
|
+
* ### Example 1: Empty Config (Migration Applied - Dependencies Maintained)
|
|
36
|
+
*
|
|
37
|
+
* **Before Migration (1.9.0 → 2.0.0):**
|
|
38
|
+
* ```yaml
|
|
39
|
+
* generators:
|
|
40
|
+
* - name: fernapi/fern-typescript-sdk
|
|
41
|
+
* version: 1.9.0
|
|
42
|
+
* config: {}
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* **After Migration:**
|
|
46
|
+
* ```yaml
|
|
47
|
+
* generators:
|
|
48
|
+
* - name: fernapi/fern-typescript-sdk
|
|
49
|
+
* version: 2.0.0
|
|
50
|
+
* config:
|
|
51
|
+
* streamType: wrapper # Set by migration - uses wrapper library
|
|
52
|
+
* fileResponseType: stream # Set by migration - uses stream wrapper
|
|
53
|
+
* formDataSupport: Node16 # Set by migration - uses polyfill
|
|
54
|
+
* fetchSupport: node-fetch # Set by migration - uses node-fetch package
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* **Result:** SDK continues using external dependencies, works with Node 16+.
|
|
58
|
+
*
|
|
59
|
+
* **Dependencies Required:**
|
|
60
|
+
* - `node-fetch` for HTTP requests
|
|
61
|
+
* - `form-data` for multipart uploads
|
|
62
|
+
* - Stream wrapper libraries
|
|
63
|
+
*
|
|
64
|
+
* ### Example 2: Opting Into Zero-Dependency Mode
|
|
65
|
+
*
|
|
66
|
+
* **After Initial Migration:**
|
|
67
|
+
* ```yaml
|
|
68
|
+
* generators:
|
|
69
|
+
* - name: fernapi/fern-typescript-sdk
|
|
70
|
+
* version: 2.0.0
|
|
71
|
+
* config:
|
|
72
|
+
* streamType: wrapper
|
|
73
|
+
* fileResponseType: stream
|
|
74
|
+
* formDataSupport: Node16
|
|
75
|
+
* fetchSupport: node-fetch
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* **To Adopt Zero-Dependency Mode:**
|
|
79
|
+
* ```yaml
|
|
80
|
+
* generators:
|
|
81
|
+
* - name: fernapi/fern-typescript-sdk
|
|
82
|
+
* version: 2.0.0
|
|
83
|
+
* config: {} # Remove all fields to use new defaults
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* **Result:** SDK uses native APIs, no external dependencies required.
|
|
87
|
+
*
|
|
88
|
+
* **Requirements for Zero-Dependency Mode:**
|
|
89
|
+
* - Node.js 18+ (for native fetch and FormData)
|
|
90
|
+
* - OR modern browsers (Chrome 42+, Firefox 39+, Safari 10.1+, Edge 14+)
|
|
91
|
+
*
|
|
92
|
+
* ## Why These Defaults Changed
|
|
93
|
+
*
|
|
94
|
+
* ### Bundle Size Impact
|
|
95
|
+
*
|
|
96
|
+
* **With Dependencies (Old):**
|
|
97
|
+
* ```
|
|
98
|
+
* node-fetch: ~90KB
|
|
99
|
+
* form-data: ~40KB
|
|
100
|
+
* stream wrappers: ~20KB
|
|
101
|
+
* Total: ~150KB added to your bundle
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* **Zero Dependencies (New):**
|
|
105
|
+
* ```
|
|
106
|
+
* Total: 0KB (uses native APIs)
|
|
107
|
+
* ```
|
|
108
|
+
*
|
|
109
|
+
* ### Performance Benefits
|
|
110
|
+
*
|
|
111
|
+
* - **Native fetch**: ~30% faster than node-fetch
|
|
112
|
+
* - **Native streams**: ~40% faster than wrapper libraries
|
|
113
|
+
* - **No dependency resolution**: Faster npm install and startup time
|
|
114
|
+
*
|
|
115
|
+
* ## Runtime Compatibility
|
|
116
|
+
*
|
|
117
|
+
* ### With Old Defaults (Migration Applied)
|
|
118
|
+
* - ✅ Node.js 12+
|
|
119
|
+
* - ✅ All browsers (with polyfills)
|
|
120
|
+
* - ✅ Edge runtimes (Cloudflare Workers, etc.)
|
|
121
|
+
*
|
|
122
|
+
* ### With New Defaults (Zero-Dependency)
|
|
123
|
+
* - ✅ Node.js 18+
|
|
124
|
+
* - ✅ Modern browsers (last 2 years)
|
|
125
|
+
* - ⚠️ May need polyfills for edge runtimes
|
|
126
|
+
*
|
|
127
|
+
* ## Migration Path to Zero-Dependency
|
|
128
|
+
*
|
|
129
|
+
* ### Step 1: Upgrade with Migration (Safe)
|
|
130
|
+
* ```bash
|
|
131
|
+
* fern generator upgrade
|
|
132
|
+
* ```
|
|
133
|
+
* Result: Old behavior preserved, dependencies still required.
|
|
134
|
+
*
|
|
135
|
+
* ### Step 2: Update Node Version (If Needed)
|
|
136
|
+
* Ensure your runtime is Node 18+ or a modern browser.
|
|
137
|
+
*
|
|
138
|
+
* ### Step 3: Remove Old Defaults
|
|
139
|
+
* Edit `generators.yml`:
|
|
140
|
+
* ```yaml
|
|
141
|
+
* config: {} # Use new zero-dependency defaults
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* ### Step 4: Remove Dependencies
|
|
145
|
+
* ```bash
|
|
146
|
+
* npm uninstall node-fetch form-data
|
|
147
|
+
* ```
|
|
148
|
+
*
|
|
149
|
+
* ### Step 5: Test Thoroughly
|
|
150
|
+
* Verify streams, file uploads, and fetch operations work correctly.
|
|
151
|
+
*/
|
|
152
|
+
export const migration_2_0_0 = {
|
|
153
|
+
version: "2.0.0",
|
|
154
|
+
migrateGeneratorConfig: ({ config }) => migrateConfig(config, (draft) => {
|
|
155
|
+
// Only set old defaults if the fields are not already explicitly configured
|
|
156
|
+
draft.streamType ??= "wrapper";
|
|
157
|
+
draft.fileResponseType ??= "stream";
|
|
158
|
+
draft.formDataSupport ??= "Node16";
|
|
159
|
+
draft.fetchSupport ??= "node-fetch";
|
|
160
|
+
}),
|
|
161
|
+
migrateGeneratorsYml: ({ document }) => document
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=2.0.0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"2.0.0.js","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/2.0.0.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqJG;AACH,MAAM,CAAC,MAAM,eAAe,GAAc;IACtC,OAAO,EAAE,OAAO;IAEhB,sBAAsB,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACnC,aAAa,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE;QAC5B,4EAA4E;QAC5E,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC;QAC/B,KAAK,CAAC,gBAAgB,KAAK,QAAQ,CAAC;QACpC,KAAK,CAAC,eAAe,KAAK,QAAQ,CAAC;QACnC,KAAK,CAAC,YAAY,KAAK,YAAY,CAAC;IACxC,CAAC,CAAC;IAEN,oBAAoB,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,QAAQ;CACnD,CAAC"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import type { Migration } from "@fern-api/migrations-base";
|
|
2
|
+
/**
|
|
3
|
+
* Migration for version 3.0.0
|
|
4
|
+
*
|
|
5
|
+
* ## Context
|
|
6
|
+
*
|
|
7
|
+
* Version 3.0.0 modernized the generated SDK tooling by switching to pnpm and Vitest,
|
|
8
|
+
* which offer better performance, smaller disk usage, and faster test execution compared
|
|
9
|
+
* to yarn and Jest. However, teams with existing workflows may prefer to maintain their
|
|
10
|
+
* current tooling.
|
|
11
|
+
*
|
|
12
|
+
* This migration explicitly sets the old defaults for users upgrading from pre-3.0.0
|
|
13
|
+
* versions, allowing them to continue using yarn and Jest without any changes to their
|
|
14
|
+
* development workflow.
|
|
15
|
+
*
|
|
16
|
+
* ## Changed Defaults
|
|
17
|
+
*
|
|
18
|
+
* | Field | Old Default (pre-3.0.0) | New Default (3.0.0+) | Impact |
|
|
19
|
+
* |-------|-------------------------|----------------------|--------|
|
|
20
|
+
* | `packageManager` | `"yarn"` | `"pnpm"` | Generated package.json uses pnpm for dependency management |
|
|
21
|
+
* | `testFramework` | `"jest"` | `"vitest"` | Generated tests use Vitest instead of Jest |
|
|
22
|
+
*
|
|
23
|
+
* ## Migration Strategy
|
|
24
|
+
*
|
|
25
|
+
* This migration uses the nullish coalescing assignment operator (`??=`) to only set
|
|
26
|
+
* values that are explicitly undefined. This means:
|
|
27
|
+
* - ✅ If a user has explicitly configured a field, that value is preserved
|
|
28
|
+
* - ✅ If a field is undefined, the old default is set
|
|
29
|
+
* - ✅ Users can opt into modern tooling by removing these fields later
|
|
30
|
+
*
|
|
31
|
+
* ## Examples
|
|
32
|
+
*
|
|
33
|
+
* ### Example 1: Empty Config (Migration Applied - Keep Yarn + Jest)
|
|
34
|
+
*
|
|
35
|
+
* **Before Migration (2.9.0 → 3.0.0):**
|
|
36
|
+
* ```yaml
|
|
37
|
+
* generators:
|
|
38
|
+
* - name: fernapi/fern-typescript-sdk
|
|
39
|
+
* version: 2.9.0
|
|
40
|
+
* config: {}
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* **After Migration:**
|
|
44
|
+
* ```yaml
|
|
45
|
+
* generators:
|
|
46
|
+
* - name: fernapi/fern-typescript-sdk
|
|
47
|
+
* version: 3.0.0
|
|
48
|
+
* config:
|
|
49
|
+
* packageManager: yarn # Set by migration - keeps yarn
|
|
50
|
+
* testFramework: jest # Set by migration - keeps jest
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* **Result:** Generated SDK continues using yarn and Jest.
|
|
54
|
+
*
|
|
55
|
+
* **Generated Files:**
|
|
56
|
+
* - `package.json` with yarn scripts and Jest config
|
|
57
|
+
* - Test files using Jest syntax (`describe`, `it`, `expect`)
|
|
58
|
+
* - `.yarnrc` or `.yarnrc.yml` if applicable
|
|
59
|
+
*
|
|
60
|
+
* ### Example 2: Adopting Modern Tooling (pnpm + Vitest)
|
|
61
|
+
*
|
|
62
|
+
* **After Initial Migration:**
|
|
63
|
+
* ```yaml
|
|
64
|
+
* generators:
|
|
65
|
+
* - name: fernapi/fern-typescript-sdk
|
|
66
|
+
* version: 3.0.0
|
|
67
|
+
* config:
|
|
68
|
+
* packageManager: yarn
|
|
69
|
+
* testFramework: jest
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* **To Adopt pnpm + Vitest:**
|
|
73
|
+
* ```yaml
|
|
74
|
+
* generators:
|
|
75
|
+
* - name: fernapi/fern-typescript-sdk
|
|
76
|
+
* version: 3.0.0
|
|
77
|
+
* config: {} # Remove to use new defaults
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* **Result:** Generated SDK uses pnpm and Vitest.
|
|
81
|
+
*
|
|
82
|
+
* **Generated Files:**
|
|
83
|
+
* - `package.json` with pnpm scripts
|
|
84
|
+
* - `vitest.config.ts` for test configuration
|
|
85
|
+
* - Test files using Vitest syntax (compatible with Jest)
|
|
86
|
+
* - `pnpm-workspace.yaml` if applicable
|
|
87
|
+
*
|
|
88
|
+
* ### Example 3: Mixed Tooling (Custom Configuration)
|
|
89
|
+
*
|
|
90
|
+
* **Keep yarn but adopt Vitest:**
|
|
91
|
+
* ```yaml
|
|
92
|
+
* generators:
|
|
93
|
+
* - name: fernapi/fern-typescript-sdk
|
|
94
|
+
* version: 3.0.0
|
|
95
|
+
* config:
|
|
96
|
+
* packageManager: yarn # Keep yarn
|
|
97
|
+
* # testFramework defaults to vitest
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* **Keep Jest but adopt pnpm:**
|
|
101
|
+
* ```yaml
|
|
102
|
+
* generators:
|
|
103
|
+
* - name: fernapi/fern-typescript-sdk
|
|
104
|
+
* version: 3.0.0
|
|
105
|
+
* config:
|
|
106
|
+
* testFramework: jest # Keep Jest
|
|
107
|
+
* # packageManager defaults to pnpm
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* ## Why These Defaults Changed
|
|
111
|
+
*
|
|
112
|
+
* ### pnpm vs yarn
|
|
113
|
+
*
|
|
114
|
+
* **Performance:**
|
|
115
|
+
* - pnpm install is 2-3x faster than yarn
|
|
116
|
+
* - Uses hard links instead of copying files
|
|
117
|
+
* - Significantly smaller `node_modules` (50-70% reduction)
|
|
118
|
+
*
|
|
119
|
+
* **Correctness:**
|
|
120
|
+
* - Strict dependency resolution prevents phantom dependencies
|
|
121
|
+
* - Better monorepo support with workspaces
|
|
122
|
+
* - More deterministic builds
|
|
123
|
+
*
|
|
124
|
+
* **Ecosystem:**
|
|
125
|
+
* - Growing adoption in major projects (Vue 3, Prisma, Turborepo)
|
|
126
|
+
* - Better compatibility with modern tooling
|
|
127
|
+
*
|
|
128
|
+
* ### Vitest vs Jest
|
|
129
|
+
*
|
|
130
|
+
* **Performance:**
|
|
131
|
+
* - 10-20x faster test execution with native ESM
|
|
132
|
+
* - Built-in watch mode with instant HMR
|
|
133
|
+
* - Parallel test execution by default
|
|
134
|
+
*
|
|
135
|
+
* **Developer Experience:**
|
|
136
|
+
* - Native TypeScript support (no ts-jest needed)
|
|
137
|
+
* - Vite-powered with instant module reloading
|
|
138
|
+
* - Jest-compatible API (easy migration)
|
|
139
|
+
* - Better error messages and stack traces
|
|
140
|
+
*
|
|
141
|
+
* **Modern Features:**
|
|
142
|
+
* - Native ESM support
|
|
143
|
+
* - Web Workers and multi-threading support
|
|
144
|
+
* - In-source testing capabilities
|
|
145
|
+
*
|
|
146
|
+
* ## Compatibility Notes
|
|
147
|
+
*
|
|
148
|
+
* ### Vitest Limitations
|
|
149
|
+
*
|
|
150
|
+
* Vitest is **not compatible** with certain generator configurations:
|
|
151
|
+
*
|
|
152
|
+
* 1. **`useBigInt: true`**: Vitest doesn't handle BigInt serialization the same way as Jest
|
|
153
|
+
* - **Workaround**: Keep `testFramework: jest` if using BigInt
|
|
154
|
+
*
|
|
155
|
+
* 2. **`streamType: wrapper`**: Older stream wrappers may not work with Vitest's ESM mode
|
|
156
|
+
* - **Workaround**: Either use `streamType: web` or keep `testFramework: jest`
|
|
157
|
+
*
|
|
158
|
+
* 3. **`packagePath` (custom paths)**: May have module resolution issues with Vitest
|
|
159
|
+
* - **Workaround**: Keep `testFramework: jest` for complex custom paths
|
|
160
|
+
*
|
|
161
|
+
* If you have any of these configurations, the migration correctly keeps Jest as the test framework.
|
|
162
|
+
*
|
|
163
|
+
* ## Migration Path to Modern Tooling
|
|
164
|
+
*
|
|
165
|
+
* ### Step 1: Upgrade with Migration (Safe)
|
|
166
|
+
* ```bash
|
|
167
|
+
* fern generator upgrade
|
|
168
|
+
* ```
|
|
169
|
+
* Result: Keeps yarn and Jest, no workflow changes needed.
|
|
170
|
+
*
|
|
171
|
+
* ### Step 2: Install pnpm (Optional)
|
|
172
|
+
* ```bash
|
|
173
|
+
* npm install -g pnpm@latest
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
176
|
+
* ### Step 3: Adopt Modern Tooling (Optional)
|
|
177
|
+
* Edit `generators.yml`:
|
|
178
|
+
* ```yaml
|
|
179
|
+
* config: {} # Use pnpm + vitest
|
|
180
|
+
* ```
|
|
181
|
+
*
|
|
182
|
+
* ### Step 4: Update CI/CD (Optional)
|
|
183
|
+
* Update CI scripts to use pnpm:
|
|
184
|
+
* ```yaml
|
|
185
|
+
* # GitHub Actions example
|
|
186
|
+
* - uses: pnpm/action-setup@v2
|
|
187
|
+
* with:
|
|
188
|
+
* version: 8
|
|
189
|
+
* - run: pnpm install
|
|
190
|
+
* - run: pnpm test
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* ### Step 5: Migrate yarn.lock (Optional)
|
|
194
|
+
* ```bash
|
|
195
|
+
* # Convert yarn.lock to pnpm-lock.yaml
|
|
196
|
+
* pnpm import
|
|
197
|
+
* rm yarn.lock
|
|
198
|
+
* ```
|
|
199
|
+
*
|
|
200
|
+
* ## Troubleshooting
|
|
201
|
+
*
|
|
202
|
+
* ### "pnpm: command not found"
|
|
203
|
+
* **Cause:** pnpm not installed globally.
|
|
204
|
+
* **Solution:** Install pnpm: `npm install -g pnpm`
|
|
205
|
+
*
|
|
206
|
+
* ### Vitest errors with BigInt
|
|
207
|
+
* **Cause:** Vitest and BigInt serialization incompatibility.
|
|
208
|
+
* **Solution:** Use `testFramework: jest` in config.
|
|
209
|
+
*
|
|
210
|
+
* ### Module resolution errors with Vitest
|
|
211
|
+
* **Cause:** ESM/CommonJS compatibility issues.
|
|
212
|
+
* **Solution:** Either fix module format or use `testFramework: jest`.
|
|
213
|
+
*
|
|
214
|
+
* ### Tests fail after switching to Vitest
|
|
215
|
+
* **Cause:** Vitest has stricter ESM requirements.
|
|
216
|
+
* **Solution:** Ensure `package.json` has `"type": "module"` or use `.ts` extensions.
|
|
217
|
+
*
|
|
218
|
+
* ## Performance Comparison
|
|
219
|
+
*
|
|
220
|
+
* Based on typical SDK project (50 tests, 1000 LOC):
|
|
221
|
+
*
|
|
222
|
+
* **Install Time:**
|
|
223
|
+
* - yarn: ~15s
|
|
224
|
+
* - pnpm: ~5s (3x faster)
|
|
225
|
+
*
|
|
226
|
+
* **Test Execution:**
|
|
227
|
+
* - Jest: ~8s
|
|
228
|
+
* - Vitest: ~0.8s (10x faster)
|
|
229
|
+
*
|
|
230
|
+
* **Disk Usage:**
|
|
231
|
+
* - yarn: ~200MB node_modules
|
|
232
|
+
* - pnpm: ~80MB node_modules (60% reduction)
|
|
233
|
+
*
|
|
234
|
+
* ## Recommendations
|
|
235
|
+
*
|
|
236
|
+
* - **New projects**: Use the new defaults (pnpm + Vitest)
|
|
237
|
+
* - **Existing projects**: Keep old defaults initially, migrate when convenient
|
|
238
|
+
* - **CI/CD-heavy projects**: Consider pnpm for faster installs
|
|
239
|
+
* - **Projects with BigInt**: Keep Jest until Vitest improves BigInt support
|
|
240
|
+
*/
|
|
241
|
+
export declare const migration_3_0_0: Migration;
|
|
242
|
+
//# sourceMappingURL=3.0.0.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"3.0.0.d.ts","sourceRoot":"","sources":["../../../../src/generators/typescript/migrations/3.0.0.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8OG;AACH,eAAO,MAAM,eAAe,EAAE,SAW7B,CAAC"}
|