@shipstatic/ship 0.2.0 → 0.2.2

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 CHANGED
@@ -12,7 +12,7 @@ A modern, lightweight SDK and CLI for deploying static files, designed for both
12
12
  - **📊 Progress Tracking**: Real-time deployment progress and statistics
13
13
  - **⚡ Cancellable**: AbortSignal support for deployment cancellation
14
14
  - **🛠️ CLI Ready**: Command-line interface for automation and CI/CD
15
- - **📦 Bundle Optimized**: Lightweight builds (16KB Node, 275KB Browser)
15
+ - **📦 Bundle Optimized**: Lightweight builds (21KB Node, 185KB Browser)
16
16
  - **🎯 Unified Error System**: Consistent `ShipError` handling across all components
17
17
 
18
18
  ## Installation
@@ -29,12 +29,36 @@ npm install -g @shipstatic/ship
29
29
  npm install @shipstatic/ship
30
30
  ```
31
31
 
32
+ ## Import Patterns
33
+
34
+ ### Default Import (Main Class)
35
+ ```javascript
36
+ // ES Modules
37
+ import Ship from '@shipstatic/ship';
38
+
39
+ // CommonJS
40
+ const Ship = require('@shipstatic/ship');
41
+ ```
42
+
43
+ ### Named Imports (Utilities)
44
+ ```javascript
45
+ // ES Modules
46
+ import { ShipError } from '@shipstatic/ship';
47
+
48
+ // CommonJS
49
+ const { ShipError } = require('@shipstatic/ship');
50
+ ```
51
+
32
52
  ## Quick Start
33
53
 
34
54
  ### SDK Usage
35
55
 
36
- ```typescript
37
- import { Ship } from '@shipstatic/ship';
56
+ ```javascript
57
+ // ES Modules
58
+ import Ship from '@shipstatic/ship';
59
+
60
+ // CommonJS
61
+ const Ship = require('@shipstatic/ship');
38
62
 
39
63
  // Authenticated deployments with API key
40
64
  const ship = new Ship({
@@ -112,6 +136,7 @@ const ship = new Ship(options?: ShipOptions)
112
136
  #### Options
113
137
 
114
138
  ```typescript
139
+ // TypeScript types available for both import styles
115
140
  interface ShipOptions {
116
141
  apiUrl?: string; // API endpoint (default: https://api.shipstatic.com)
117
142
  apiKey?: string; // API key: ship- prefix + 64-char hex (69 chars total)
@@ -177,8 +202,12 @@ interface DeployOptions {
177
202
 
178
203
  #### Node.js File Deployment
179
204
 
180
- ```typescript
181
- import { Ship } from '@shipstatic/ship';
205
+ ```javascript
206
+ // ES Modules
207
+ import Ship from '@shipstatic/ship';
208
+
209
+ // CommonJS
210
+ const Ship = require('@shipstatic/ship');
182
211
 
183
212
  const ship = new Ship({
184
213
  apiUrl: 'https://api.shipstatic.com',
@@ -202,8 +231,11 @@ console.log(`✅ Deployed: ${result.deployment}`);
202
231
 
203
232
  #### Browser File Upload
204
233
 
205
- ```typescript
206
- import { Ship } from '@shipstatic/ship';
234
+ ```javascript
235
+ // ES Modules
236
+ import Ship from '@shipstatic/ship';
237
+
238
+ // Browser (ES Modules only)
207
239
 
208
240
  const ship = new Ship({
209
241
  apiUrl: 'https://api.shipstatic.com',
@@ -227,9 +259,13 @@ const result2 = await ship.deployments.create(files);
227
259
 
228
260
  The Ship SDK uses a unified error system with a single `ShipError` class:
229
261
 
230
- ```typescript
262
+ ```javascript
263
+ // ES Modules
231
264
  import { ShipError } from '@shipstatic/ship';
232
265
 
266
+ // CommonJS
267
+ const { ShipError } = require('@shipstatic/ship');
268
+
233
269
  try {
234
270
  await ship.deployments.create(['./dist']);
235
271
  } catch (error) {
@@ -378,9 +414,9 @@ ship account # Get account details
378
414
  ## Bundle Sizes
379
415
 
380
416
  **Optimized for production:**
381
- - **Node.js**: 16KB (ESM), 17KB (CJS)
382
- - **Browser**: 275KB (ESM with dependencies)
383
- - **CLI**: 25KB (CJS)
417
+ - **Node.js**: 21KB (ESM), 21KB (CJS)
418
+ - **Browser**: 185KB (ESM with dependencies)
419
+ - **CLI**: 38KB (CJS)
384
420
 
385
421
  **Recent Optimizations:**
386
422
  - ✅ **Unified error system** - Single `ShipError` class for all components
@@ -395,6 +431,7 @@ ship account # Get account details
395
431
  Full TypeScript support with exported types from shared `@shipstatic/types`:
396
432
 
397
433
  ```typescript
434
+ // TypeScript - works with both import styles
398
435
  import type {
399
436
  ShipOptions,
400
437
  NodeDeployInput,
@@ -421,17 +458,23 @@ import type {
421
458
  ### Codebase Organization
422
459
  ```
423
460
  src/
424
- ├── core/ # Cross-cutting concerns
425
- │ ├── config.ts # Configuration loading and merging
426
- └── constants.ts # Platform constants and defaults
427
- ├── lib/ # Utility libraries (renamed from utils/)
428
- ├── env.js # Environment detection
429
- │ ├── node-files.ts # Node.js file system operations
430
- │ ├── prepare-input.ts # Input preparation (renamed from input-conversion.ts)
431
- └── path.ts # Path utilities (renamed from path-helpers.ts)
432
- ├── cli.ts # CLI implementation (moved from cli/index.ts)
433
- ├── index.ts # Main SDK exports
434
- └── types.ts # All SDK types (consolidated from types/)
461
+ ├── browser/ # Browser-specific implementations
462
+ │ ├── core/ # Browser configuration and setup
463
+ ├── index.ts # Browser SDK exports
464
+ │ └── lib/ # Browser file handling
465
+ ├── node/ # Node.js-specific implementations
466
+ │ ├── cli/ # CLI command implementations
467
+ │ ├── completions/ # Shell completion scripts
468
+ ├── core/ # Node.js configuration and file handling
469
+ │ └── index.ts # Node.js SDK exports
470
+ ├── shared/ # Cross-platform shared code
471
+ │ ├── api/ # HTTP client and API communication
472
+ │ ├── base-ship.ts # Base Ship class implementation
473
+ │ ├── core/ # Configuration and constants
474
+ │ ├── lib/ # Utility libraries
475
+ │ ├── resources.ts # Resource implementations
476
+ │ └── types.ts # Shared type definitions
477
+ └── index.ts # Main SDK exports with environment detection
435
478
 
436
479
  ### File Processing Pipeline
437
480
  **Node.js:**
@@ -470,6 +513,7 @@ This is an **unlaunched project** optimized for modern development:
470
513
  - ✅ **Streamlined Multipart**: `files[]` array + JSON checksums format
471
514
  - ✅ **Direct Validation**: Functions throw errors instead of returning results
472
515
  - ✅ **Shared DTOs**: All types from `@shipstatic/types` package
516
+ - ✅ **Tree-shakeable**: `"sideEffects": false` for optimal bundling
473
517
  - ✅ **Impossible Simplicity**: Maximum functionality with minimal complexity
474
518
  - 🎯 No legacy compatibility constraints
475
519
  - 🔧 Native fetch API for optimal performance
@@ -499,7 +543,7 @@ pnpm build && pnpm test --run
499
543
  - **Node.js tests**: Filesystem and path manipulation
500
544
  - **Error tests**: Unified error handling patterns
501
545
 
502
- **Current Status:** 264 tests passing ✅
546
+ **Current Status:** 566 tests passing (596 total)
503
547
 
504
548
  ## Contributing
505
549