@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 +67 -23
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +13 -13
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +31 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
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 (
|
|
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
|
-
```
|
|
37
|
-
|
|
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
|
-
```
|
|
181
|
-
|
|
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
|
-
```
|
|
206
|
-
|
|
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
|
-
```
|
|
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**:
|
|
382
|
-
- **Browser**:
|
|
383
|
-
- **CLI**:
|
|
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
|
-
├──
|
|
425
|
-
│ ├──
|
|
426
|
-
│
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
│ ├──
|
|
430
|
-
│ ├──
|
|
431
|
-
│
|
|
432
|
-
|
|
433
|
-
├──
|
|
434
|
-
|
|
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:**
|
|
546
|
+
**Current Status:** 566 tests passing (596 total) ✅
|
|
503
547
|
|
|
504
548
|
## Contributing
|
|
505
549
|
|