@diviswap/sdk 1.7.6

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.
Files changed (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +510 -0
  3. package/bin/create-diviswap-app.js +25 -0
  4. package/bin/diviswap-sdk.js +4 -0
  5. package/dist/cli/index.js +1888 -0
  6. package/dist/cli/templates/nextjs-app/actions.ts.hbs +259 -0
  7. package/dist/cli/templates/nextjs-app/api-hooks.ts.hbs +439 -0
  8. package/dist/cli/templates/nextjs-app/api-route.ts.hbs +502 -0
  9. package/dist/cli/templates/nextjs-app/auth-context.tsx.hbs +59 -0
  10. package/dist/cli/templates/nextjs-app/client.ts.hbs +116 -0
  11. package/dist/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +180 -0
  12. package/dist/cli/templates/nextjs-app/example-page.tsx.hbs +276 -0
  13. package/dist/cli/templates/nextjs-app/hooks.ts.hbs +252 -0
  14. package/dist/cli/templates/nextjs-app/kyc-hooks.ts.hbs +87 -0
  15. package/dist/cli/templates/nextjs-app/kyc-wizard.css.hbs +433 -0
  16. package/dist/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +711 -0
  17. package/dist/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +13 -0
  18. package/dist/cli/templates/nextjs-app/layout.tsx.hbs +13 -0
  19. package/dist/cli/templates/nextjs-app/middleware.ts.hbs +49 -0
  20. package/dist/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +8 -0
  21. package/dist/cli/templates/nextjs-app/provider.tsx.hbs +408 -0
  22. package/dist/cli/templates/nextjs-app/setup-provider.tsx.hbs +25 -0
  23. package/dist/cli/templates/nextjs-app/types.ts.hbs +159 -0
  24. package/dist/cli/templates/react/api-client-wrapper.ts.hbs +89 -0
  25. package/dist/cli/templates/react/example.tsx.hbs +69 -0
  26. package/dist/cli/templates/react/tanstack-hooks.ts.hbs +185 -0
  27. package/dist/cli/templates/webhooks/nextjs.hbs +98 -0
  28. package/dist/index.d.mts +91 -0
  29. package/dist/index.d.ts +91 -0
  30. package/dist/index.js +2339 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/index.mjs +2313 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/dist/react/index.d.mts +192 -0
  35. package/dist/react/index.d.ts +192 -0
  36. package/dist/react/index.js +1083 -0
  37. package/dist/react/index.js.map +1 -0
  38. package/dist/react/index.mjs +1064 -0
  39. package/dist/react/index.mjs.map +1 -0
  40. package/dist/wallet-BEGvzNtB.d.mts +1614 -0
  41. package/dist/wallet-BEGvzNtB.d.ts +1614 -0
  42. package/package.json +102 -0
  43. package/src/cli/templates/index.ts +65 -0
  44. package/src/cli/templates/nextjs-app/actions.ts.hbs +259 -0
  45. package/src/cli/templates/nextjs-app/api-hooks.ts.hbs +439 -0
  46. package/src/cli/templates/nextjs-app/api-route.ts.hbs +502 -0
  47. package/src/cli/templates/nextjs-app/auth-context.tsx.hbs +59 -0
  48. package/src/cli/templates/nextjs-app/client.ts.hbs +116 -0
  49. package/src/cli/templates/nextjs-app/dashboard-hooks.ts.hbs +180 -0
  50. package/src/cli/templates/nextjs-app/example-page.tsx.hbs +276 -0
  51. package/src/cli/templates/nextjs-app/hooks.ts.hbs +252 -0
  52. package/src/cli/templates/nextjs-app/kyc-hooks.ts.hbs +87 -0
  53. package/src/cli/templates/nextjs-app/kyc-wizard.css.hbs +433 -0
  54. package/src/cli/templates/nextjs-app/kyc-wizard.tsx.hbs +711 -0
  55. package/src/cli/templates/nextjs-app/layout-wrapper.tsx.hbs +13 -0
  56. package/src/cli/templates/nextjs-app/layout.tsx.hbs +13 -0
  57. package/src/cli/templates/nextjs-app/middleware.ts.hbs +49 -0
  58. package/src/cli/templates/nextjs-app/provider-wrapper.tsx.hbs +8 -0
  59. package/src/cli/templates/nextjs-app/provider.tsx.hbs +408 -0
  60. package/src/cli/templates/nextjs-app/setup-provider.tsx.hbs +25 -0
  61. package/src/cli/templates/nextjs-app/types.ts.hbs +159 -0
  62. package/src/cli/templates/react/api-client-wrapper.ts.hbs +89 -0
  63. package/src/cli/templates/react/example.tsx.hbs +69 -0
  64. package/src/cli/templates/react/tanstack-hooks.ts.hbs +185 -0
  65. package/src/cli/templates/shared/client.ts +78 -0
  66. package/src/cli/templates/webhooks/nextjs.hbs +98 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 LiberEx
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,510 @@
1
+ # Diviswap SDK
2
+
3
+ The official TypeScript/JavaScript SDK for Diviswap - crypto rails made simple. Get up and running in under 9 minutes!
4
+
5
+ ## Quick Start
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ npm install @diviswap/sdk
11
+ # or
12
+ yarn add @diviswap/sdk
13
+ # or
14
+ pnpm add @diviswap/sdk
15
+ ```
16
+
17
+ ### Basic Usage
18
+
19
+ ```typescript
20
+ import Diviswap from '@diviswap/sdk';
21
+
22
+ // Initialize the SDK
23
+ const diviswap = Diviswap.init({
24
+ apiKey: 'your-api-key',
25
+ clientId: 'your-client-id',
26
+ environment: 'sandbox' // or 'production'
27
+ });
28
+
29
+ // Register a new user
30
+ const { user } = await diviswap.auth.register({
31
+ email: 'user@example.com',
32
+ password: 'secure-password'
33
+ });
34
+
35
+ // Check KYC status
36
+ const compliance = await diviswap.kyc.getComplianceStatus();
37
+ if (!compliance.canTransact) {
38
+ // Start KYC verification
39
+ const session = await diviswap.kyc.startKycSession();
40
+ // Redirect user to complete KYC
41
+ window.location.href = session.sessionUrl;
42
+ return;
43
+ }
44
+
45
+ // Create a bank account (payee)
46
+ const payee = await diviswap.payees.create({
47
+ nickname: 'My Bank',
48
+ accountNumber: '123456789',
49
+ routingNumber: '021000021',
50
+ accountType: 'checking'
51
+ });
52
+
53
+ // Create an onramp transaction (buy crypto)
54
+ const transaction = await diviswap.transactions.onramp({
55
+ amount: 100,
56
+ currency: 'USD',
57
+ payeeId: payee.id,
58
+ toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E123'
59
+ });
60
+ ```
61
+
62
+ ## Features
63
+
64
+ - **Simple Authentication** - Register and login with just email/password
65
+ - **Bank Account Management** - Add and verify bank accounts easily
66
+ - **Crypto On/Off Ramps** - Convert between fiat and crypto seamlessly
67
+ - **Address Management** - Automatic wallet tracking and manual address management
68
+ - **Automatic Token Refresh** - Never worry about expired tokens
69
+ - **TypeScript Support** - Full type safety and IntelliSense
70
+ - **Multi-Environment** - Support for production, sandbox, and local development
71
+ - **Lightweight** - Minimal dependencies, uses native fetch
72
+
73
+ ## API Reference
74
+
75
+ ### Authentication
76
+
77
+ ```typescript
78
+ // Register new user
79
+ await diviswap.auth.register({
80
+ email: 'user@example.com',
81
+ password: 'password',
82
+ firstName: 'John',
83
+ lastName: 'Doe'
84
+ });
85
+
86
+ // Login existing user
87
+ await diviswap.auth.login({
88
+ email: 'user@example.com',
89
+ password: 'password'
90
+ });
91
+
92
+ // Get user profile
93
+ const user = await diviswap.auth.getProfile();
94
+
95
+ // Logout
96
+ await diviswap.auth.logout();
97
+ ```
98
+
99
+ ### KYC Verification
100
+
101
+ ```typescript
102
+ // Check compliance status
103
+ const status = await diviswap.kyc.getComplianceStatus();
104
+ if (!status.canTransact) {
105
+ console.log('KYC required:', status.nextStep);
106
+ }
107
+
108
+ // Start KYC verification
109
+ const session = await diviswap.kyc.startKycSession();
110
+ // Redirect to: session.sessionUrl
111
+
112
+ // Check if KYC approved
113
+ const isApproved = await diviswap.kyc.isKycApproved();
114
+
115
+ // Wait for approval (polling)
116
+ try {
117
+ await diviswap.kyc.waitForApproval({
118
+ pollInterval: 5000,
119
+ maxAttempts: 60
120
+ });
121
+ } catch (error) {
122
+ console.log('KYC not approved');
123
+ }
124
+
125
+ // Get rejection reasons
126
+ if (status.kycStatus === 'REJECTED') {
127
+ const reasons = await diviswap.kyc.getRejectionReasons();
128
+ }
129
+ ```
130
+
131
+ ### Payees (Bank Accounts)
132
+
133
+ ```typescript
134
+ // Create payee
135
+ const payee = await diviswap.payees.create({
136
+ nickname: 'My Checking',
137
+ accountNumber: '123456789',
138
+ routingNumber: '021000021',
139
+ accountType: 'checking'
140
+ });
141
+
142
+ // List all payees
143
+ const payees = await diviswap.payees.list();
144
+
145
+ // Set default payee
146
+ await diviswap.payees.setDefault(payee.id);
147
+
148
+ // Verify with micro-deposits
149
+ await diviswap.payees.verify(payee.id, {
150
+ amount1: 0.32,
151
+ amount2: 0.45
152
+ });
153
+ ```
154
+
155
+ ### Transactions
156
+
157
+ ```typescript
158
+ // Onramp (buy crypto with fiat)
159
+ const onramp = await diviswap.transactions.onramp({
160
+ amount: 100,
161
+ currency: 'USD',
162
+ payeeId: 'payee-id',
163
+ toAddress: '0x...'
164
+ });
165
+
166
+ // Offramp (sell crypto for fiat)
167
+ const offramp = await diviswap.transactions.offramp({
168
+ amount: 0.5,
169
+ currency: 'ETH',
170
+ fromAddress: '0x...',
171
+ payeeId: 'payee-id'
172
+ });
173
+
174
+ // List transactions
175
+ const transactions = await diviswap.transactions.list({
176
+ type: 'onramp',
177
+ status: 'completed'
178
+ });
179
+
180
+ // Get fee estimate
181
+ const estimate = await diviswap.transactions.estimateFees({
182
+ amount: 100,
183
+ currency: 'USD',
184
+ type: 'onramp'
185
+ });
186
+ ```
187
+
188
+ ### Address Management
189
+
190
+ #### Automatic Wallet Tracking (Recommended)
191
+
192
+ ```typescript
193
+ import { Diviswap, connectWallet, trackCurrentWallet, setupWalletTracking } from '@diviswap/sdk';
194
+
195
+ const diviswap = Diviswap.init(config);
196
+
197
+ // Connect and automatically track wallet
198
+ const connections = await connectWallet(diviswap);
199
+ console.log('Tracked addresses:', connections);
200
+
201
+ // Track current wallet state without requesting permission
202
+ const current = await trackCurrentWallet(diviswap);
203
+
204
+ // Setup automatic tracking for account/chain changes
205
+ const tracker = setupWalletTracking(diviswap, {
206
+ trackAccountChanges: true,
207
+ trackChainChanges: true,
208
+ setAsDefault: true
209
+ });
210
+ ```
211
+
212
+ #### Manual Address Management
213
+
214
+ ```typescript
215
+ // Create address manually
216
+ const address = await diviswap.addresses.create({
217
+ chain_id: 1, // Ethereum mainnet
218
+ address: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E123',
219
+ is_default: true
220
+ });
221
+
222
+ // List all addresses
223
+ const addresses = await diviswap.addresses.list();
224
+
225
+ // Filter by chain
226
+ const ethAddresses = await diviswap.addresses.list({ chain_id: 1 });
227
+
228
+ // Get default addresses only
229
+ const defaults = await diviswap.addresses.list({ is_default: true });
230
+
231
+ // Set address as default for its chain
232
+ await diviswap.addresses.setDefault({
233
+ chain_id: 1,
234
+ address: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E123'
235
+ });
236
+
237
+ // Delete address
238
+ await diviswap.addresses.delete({
239
+ chain_id: 1,
240
+ address: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E123'
241
+ });
242
+
243
+ // Convenience methods
244
+ const ethAddresses = await diviswap.addresses.getByChain('ethereum');
245
+ const defaultEth = await diviswap.addresses.getDefault('ethereum');
246
+ const chainId = diviswap.addresses.getChainId('base'); // Returns 8453
247
+ ```
248
+
249
+ #### React Hooks for Addresses
250
+
251
+ ```typescript
252
+ import { useAddresses, useWalletConnection, useWalletAddresses } from '@diviswap/sdk/react';
253
+
254
+ function AddressManager() {
255
+ const { addresses, loading, createAddress, setDefaultAddress } = useAddresses(diviswap);
256
+
257
+ const { connections, connect, isConnecting } = useWalletConnection(diviswap);
258
+
259
+ // Combined hook for wallet + address management
260
+ const {
261
+ addresses,
262
+ connections,
263
+ connectAndTrack,
264
+ isConnecting
265
+ } = useWalletAddresses(diviswap);
266
+
267
+ return (
268
+ <div>
269
+ <button onClick={() => connectAndTrack()} disabled={isConnecting}>
270
+ {isConnecting ? 'Connecting...' : 'Connect Wallet'}
271
+ </button>
272
+
273
+ {addresses.map(addr => (
274
+ <div key={`${addr.chain_id}-${addr.address}`}>
275
+ {addr.address} {addr.is_default && '(Default)'}
276
+ </div>
277
+ ))}
278
+ </div>
279
+ );
280
+ }
281
+ ```
282
+
283
+ #### Supported Chains
284
+
285
+ ```typescript
286
+ import { CHAIN_IDS } from '@diviswap/sdk';
287
+
288
+ // Mainnets
289
+ CHAIN_IDS.ethereum // 1
290
+ CHAIN_IDS.optimism // 10
291
+ CHAIN_IDS.base // 8453
292
+ CHAIN_IDS.polygon // 137
293
+ CHAIN_IDS.arbitrum // 42161
294
+
295
+ // Testnets
296
+ CHAIN_IDS.sepolia // 11155111
297
+ CHAIN_IDS.optimismSepolia // 11155420
298
+ CHAIN_IDS.baseSepolia // 84532
299
+ CHAIN_IDS.polygonAmoy // 80002
300
+ CHAIN_IDS.arbitrumSepolia // 421614
301
+ ```
302
+
303
+ ### Fee Management (Monetization)
304
+
305
+ ```typescript
306
+ // Set your custom fee (default is 0.5%)
307
+ await diviswap.fees.setFee({ percentage: 0.75 });
308
+
309
+ // Calculate fees for transparency
310
+ const calc = await diviswap.fees.calculateFees({ amount: 100 });
311
+ console.log(`Diviswap fee: $${calc.baseFee} (1.5%)`);
312
+ console.log(`Your earnings: $${calc.integratorFee} (0.75%)`);
313
+ console.log(`Total fee: $${calc.totalFee}`);
314
+
315
+ // Track your earnings
316
+ const earnings = await diviswap.fees.getEarnings({
317
+ startDate: '2024-01-01',
318
+ endDate: '2024-01-31'
319
+ });
320
+ console.log(`Monthly revenue: $${earnings.totalEarned}`);
321
+ ```
322
+
323
+ ## Monetization
324
+
325
+ Earn revenue from every transaction with customizable integrator fees:
326
+
327
+ - **Default 0.5% fee** - Start earning immediately
328
+ - **Fully customizable** - Set any fee percentage
329
+ - **Per-user pricing** - Different fees for different user tiers
330
+ - **Transparent** - Users see exact fee breakdowns
331
+ - **Real-time tracking** - Monitor your earnings
332
+
333
+ See the [Integrator Fees Guide](docs/guides/integrator-fees.md) for details.
334
+
335
+ ## Configuration
336
+
337
+ ### Initialization Options
338
+
339
+ ```typescript
340
+ Diviswap.init({
341
+ apiKey: 'your-api-key', // Required
342
+ clientId: 'your-client-id', // Required
343
+ environment: 'production', // Optional: 'production' | 'sandbox' | 'development'
344
+ apiUrl: 'https://custom.api', // Optional: Override default API URL
345
+ debug: false, // Optional: Enable debug logging
346
+ timeout: 30000, // Optional: Request timeout in ms
347
+ defaultFee: 0.5 // Optional: Your default fee % (default: 0.5)
348
+ });
349
+ ```
350
+
351
+ ### Environments
352
+
353
+ - **Production**: `https://api.diviswap.io`
354
+ - **Sandbox**: `https://sandbox.api.diviswap.io`
355
+ - **Development**: `http://localhost:5000`
356
+
357
+ ## Security
358
+
359
+ - API keys and Client IDs are required for all requests
360
+ - Requests are signed with HMAC-SHA256
361
+ - Tokens are automatically refreshed when expired
362
+ - Sensitive data is never logged in debug mode
363
+ - KYC verification required before transactions
364
+ - All user data encrypted and stored securely
365
+
366
+ ## Examples
367
+
368
+ ### Complete Onramp Flow
369
+
370
+ ```typescript
371
+ import Diviswap from '@diviswap/sdk';
372
+
373
+ async function buyBitcoin() {
374
+ // Initialize SDK
375
+ const diviswap = Diviswap.init({
376
+ apiKey: process.env.DIVISWAP_API_KEY,
377
+ clientId: process.env.DIVISWAP_CLIENT_ID,
378
+ environment: 'sandbox'
379
+ });
380
+
381
+ try {
382
+ // Login user
383
+ await diviswap.auth.login({
384
+ email: 'user@example.com',
385
+ password: 'password'
386
+ });
387
+
388
+ // Check KYC status
389
+ const compliance = await diviswap.kyc.getComplianceStatus();
390
+ if (!compliance.canTransact) {
391
+ console.log('KYC verification required');
392
+ const session = await diviswap.kyc.startKycSession();
393
+ console.log('Complete KYC at:', session.sessionUrl);
394
+ return;
395
+ }
396
+
397
+ // Get or create a payee
398
+ let payee = await diviswap.payees.getDefault();
399
+ if (!payee) {
400
+ payee = await diviswap.payees.create({
401
+ nickname: 'My Bank',
402
+ accountNumber: '123456789',
403
+ routingNumber: '021000021',
404
+ accountType: 'checking',
405
+ setAsDefault: true
406
+ });
407
+ }
408
+
409
+ // Check fee estimate
410
+ const estimate = await diviswap.transactions.estimateFees({
411
+ amount: 100,
412
+ currency: 'USD',
413
+ type: 'onramp'
414
+ });
415
+
416
+ console.log(`You'll pay $${estimate.fee} in fees`);
417
+
418
+ // Create transaction
419
+ const tx = await diviswap.transactions.onramp({
420
+ amount: 100,
421
+ currency: 'USD',
422
+ payeeId: payee.id,
423
+ toAddress: '0x742d35Cc6634C0532925a3b844Bc9e7595f6E123'
424
+ });
425
+
426
+ console.log(`Transaction ${tx.id} created!`);
427
+
428
+ } catch (error) {
429
+ console.error('Error:', error);
430
+ }
431
+ }
432
+
433
+ buyBitcoin();
434
+ ```
435
+
436
+ ### Complete Wallet Integration Flow
437
+
438
+ ```typescript
439
+ import { Diviswap, connectWallet, useWalletAddresses } from '@diviswap/sdk';
440
+
441
+ async function integrateWallet() {
442
+ const diviswap = Diviswap.init({
443
+ apiKey: process.env.DIVISWAP_API_KEY,
444
+ clientId: process.env.DIVISWAP_CLIENT_ID,
445
+ environment: 'sandbox'
446
+ });
447
+
448
+ try {
449
+ // Connect user's wallet and automatically track addresses
450
+ const connections = await connectWallet(diviswap);
451
+ console.log('Connected wallets:', connections);
452
+
453
+ // Get user's tracked addresses
454
+ const addresses = await diviswap.addresses.list();
455
+ console.log('User addresses:', addresses);
456
+
457
+ // Use default Ethereum address for offramp
458
+ const defaultEth = await diviswap.addresses.getDefault('ethereum');
459
+
460
+ if (defaultEth) {
461
+ // Create offramp transaction using tracked address
462
+ const tx = await diviswap.transactions.offramp({
463
+ amount: 0.1,
464
+ currency: 'ETH',
465
+ fromAddress: defaultEth.address,
466
+ txHash: '0x...', // Transaction hash from user's wallet
467
+ chain: 'ethereum',
468
+ payeeId: 'user-bank-account-id'
469
+ });
470
+
471
+ console.log('Offramp created:', tx.id);
472
+ }
473
+
474
+ } catch (error) {
475
+ console.error('Error:', error);
476
+ }
477
+ }
478
+
479
+ integrateWallet();
480
+ ```
481
+
482
+ ## Error Handling
483
+
484
+ The SDK throws typed errors for different scenarios:
485
+
486
+ ```typescript
487
+ import { DiviswapError, AuthenticationError, ValidationError } from '@diviswap/sdk';
488
+
489
+ try {
490
+ await diviswap.auth.login(credentials);
491
+ } catch (error) {
492
+ if (error instanceof AuthenticationError) {
493
+ console.error('Invalid credentials');
494
+ } else if (error instanceof ValidationError) {
495
+ console.error('Invalid input:', error.details);
496
+ } else if (error instanceof DiviswapError) {
497
+ console.error('API error:', error.message);
498
+ }
499
+ }
500
+ ```
501
+
502
+ ## Support
503
+
504
+ - Email: support@diviswap.io
505
+ - Documentation: https://docs.diviswap.io
506
+ - Issues: https://github.com/diviswap/sdk/issues
507
+
508
+ ## License
509
+
510
+ MIT
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env node
2
+
3
+ // This file enables `npx @diviswap/sdk` to work
4
+ // It simply forwards to the main CLI with the create-app command
5
+
6
+ const { spawn } = require('child_process');
7
+ const { join } = require('path');
8
+
9
+ const cliPath = join(__dirname, '..', 'dist', 'cli', 'index.js');
10
+
11
+ // Forward all arguments to the main CLI, defaulting to create-app if no command specified
12
+ const args = process.argv.slice(2);
13
+ if (args.length === 0 || !args[0].startsWith('-')) {
14
+ // If no args or first arg is not a flag, assume create-app
15
+ args.unshift('create-app');
16
+ }
17
+
18
+ const child = spawn('node', [cliPath, ...args], {
19
+ stdio: 'inherit',
20
+ env: process.env
21
+ });
22
+
23
+ child.on('exit', (code) => {
24
+ process.exit(code || 0);
25
+ });
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ // This file wraps the compiled CLI
4
+ require('../dist/cli/index.js');