@shipstatic/ship 0.3.4 → 0.3.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.
- package/README.md +8 -8
- package/dist/browser.d.ts +84 -29
- package/dist/browser.js +3 -3
- package/dist/browser.js.map +1 -1
- package/dist/cli.cjs +17 -17
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +84 -29
- package/dist/index.d.ts +84 -29
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,7 +76,7 @@ const ship = new Ship({
|
|
|
76
76
|
|
|
77
77
|
// Deploy project - SDK automatically fetches platform configuration
|
|
78
78
|
const result = await ship.deployments.create(['./dist'], {
|
|
79
|
-
onProgress: (
|
|
79
|
+
onProgress: ({ percent }) => console.log(`${percent}%`)
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
console.log(`Deployed: ${result.deployment}`);
|
|
@@ -201,6 +201,7 @@ interface ShipOptions {
|
|
|
201
201
|
apiKey?: string; // API key: ship- prefix + 64-char hex (69 chars total)
|
|
202
202
|
deployToken?: string; // Deploy token: token- prefix + 64-char hex (70 chars total)
|
|
203
203
|
timeout?: number; // Request timeout (ms)
|
|
204
|
+
useCredentials?: boolean; // Use HTTP-only cookies for auth (skips token check)
|
|
204
205
|
}
|
|
205
206
|
```
|
|
206
207
|
|
|
@@ -259,8 +260,7 @@ interface DeployOptions {
|
|
|
259
260
|
signal?: AbortSignal; // Cancellation
|
|
260
261
|
subdomain?: string; // Custom subdomain
|
|
261
262
|
onCancel?: () => void;
|
|
262
|
-
onProgress?: (
|
|
263
|
-
progress?: (stats: ProgressStats) => void;
|
|
263
|
+
onProgress?: (info: ProgressInfo) => void; // Progress with percent (0-100), loaded, total bytes
|
|
264
264
|
maxConcurrency?: number;
|
|
265
265
|
timeout?: number;
|
|
266
266
|
stripCommonPrefix?: boolean; // Remove common path prefix
|
|
@@ -321,8 +321,8 @@ const result = await ship.deployments.create([
|
|
|
321
321
|
'./public'
|
|
322
322
|
], {
|
|
323
323
|
stripCommonPrefix: true,
|
|
324
|
-
onProgress: (
|
|
325
|
-
console.log(`Deployment: ${
|
|
324
|
+
onProgress: ({ percent }) => {
|
|
325
|
+
console.log(`Deployment: ${percent}% complete`);
|
|
326
326
|
}
|
|
327
327
|
});
|
|
328
328
|
|
|
@@ -346,8 +346,8 @@ const ship = new Ship({
|
|
|
346
346
|
const fileInput = document.getElementById('fileInput') as HTMLInputElement;
|
|
347
347
|
const files: File[] = Array.from(fileInput.files || []);
|
|
348
348
|
const result = await ship.deployments.create(files, {
|
|
349
|
-
onProgress: (
|
|
350
|
-
document.getElementById('progress').textContent = `${
|
|
349
|
+
onProgress: ({ percent }) => {
|
|
350
|
+
document.getElementById('progress').textContent = `${percent}%`;
|
|
351
351
|
}
|
|
352
352
|
});
|
|
353
353
|
```
|
|
@@ -691,7 +691,7 @@ import type {
|
|
|
691
691
|
BrowserDeployInput,
|
|
692
692
|
DeployOptions,
|
|
693
693
|
DeploySuccessResponse,
|
|
694
|
-
|
|
694
|
+
ProgressInfo,
|
|
695
695
|
StaticFile,
|
|
696
696
|
ShipError,
|
|
697
697
|
ErrorType
|
package/dist/browser.d.ts
CHANGED
|
@@ -35,10 +35,8 @@ interface DeploymentOptions {
|
|
|
35
35
|
spaDetect?: boolean;
|
|
36
36
|
/** Optional array of tags for categorization and filtering (lowercase, alphanumeric with separators). */
|
|
37
37
|
tags?: string[];
|
|
38
|
-
/** Callback for
|
|
39
|
-
onProgress?: (
|
|
40
|
-
/** Callback for detailed progress statistics. */
|
|
41
|
-
onProgressStats?: (progressStats: ProgressStats) => void;
|
|
38
|
+
/** Callback for deploy progress with detailed statistics. */
|
|
39
|
+
onProgress?: (info: ProgressInfo) => void;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Options for configuring an deploy operation via `apiClient.deployFiles`.
|
|
@@ -46,16 +44,17 @@ interface DeploymentOptions {
|
|
|
46
44
|
*/
|
|
47
45
|
type ApiDeployOptions = Omit<DeploymentOptions, 'pathDetect'>;
|
|
48
46
|
/**
|
|
49
|
-
*
|
|
47
|
+
* Progress information for deploy operations.
|
|
48
|
+
* Provides consistent percentage-based progress with byte-level details.
|
|
50
49
|
*/
|
|
51
|
-
interface
|
|
52
|
-
/**
|
|
50
|
+
interface ProgressInfo {
|
|
51
|
+
/** Progress percentage (0-100). */
|
|
52
|
+
percent: number;
|
|
53
|
+
/** Number of bytes loaded so far. */
|
|
53
54
|
loaded: number;
|
|
54
|
-
/**
|
|
55
|
+
/** Total number of bytes to be loaded. May be 0 if unknown initially. */
|
|
55
56
|
total: number;
|
|
56
|
-
/**
|
|
57
|
-
progress: number;
|
|
58
|
-
/** Optional identifier for the file this progress pertains to, if applicable. */
|
|
57
|
+
/** Current file being processed (optional). */
|
|
59
58
|
file?: string;
|
|
60
59
|
}
|
|
61
60
|
/**
|
|
@@ -72,15 +71,10 @@ interface ShipClientOptions {
|
|
|
72
71
|
/** Path to custom config file. */
|
|
73
72
|
configFile?: string | undefined;
|
|
74
73
|
/**
|
|
75
|
-
* Default callback for
|
|
76
|
-
* @param
|
|
74
|
+
* Default callback for deploy progress for deploys made with this client.
|
|
75
|
+
* @param info - Progress information including percentage and byte counts.
|
|
77
76
|
*/
|
|
78
|
-
onProgress?: ((
|
|
79
|
-
/**
|
|
80
|
-
* Default callback for detailed progress statistics for deploys made with this client.
|
|
81
|
-
* @param progressStats - Progress statistics object.
|
|
82
|
-
*/
|
|
83
|
-
onProgressStats?: ((progressStats: ProgressStats) => void) | undefined;
|
|
77
|
+
onProgress?: ((info: ProgressInfo) => void) | undefined;
|
|
84
78
|
/**
|
|
85
79
|
* Default for maximum concurrent deploys.
|
|
86
80
|
* Used if an deploy operation doesn't specify its own `maxConcurrency`.
|
|
@@ -92,6 +86,15 @@ interface ShipClientOptions {
|
|
|
92
86
|
* Used if an deploy operation doesn't specify its own timeout.
|
|
93
87
|
*/
|
|
94
88
|
timeout?: number | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* When true, indicates the client should use HTTP-only cookies for authentication
|
|
91
|
+
* instead of explicit tokens. This is useful for internal browser applications
|
|
92
|
+
* where authentication is handled via secure cookies set by the API.
|
|
93
|
+
*
|
|
94
|
+
* When set, the pre-request authentication check is skipped, allowing requests
|
|
95
|
+
* to proceed with cookie-based credentials.
|
|
96
|
+
*/
|
|
97
|
+
useCredentials?: boolean | undefined;
|
|
95
98
|
}
|
|
96
99
|
/**
|
|
97
100
|
* Event map for Ship SDK events
|
|
@@ -159,9 +162,10 @@ declare class SimpleEvents {
|
|
|
159
162
|
*/
|
|
160
163
|
declare class ApiHttp extends SimpleEvents {
|
|
161
164
|
private readonly apiUrl;
|
|
162
|
-
private readonly
|
|
163
|
-
|
|
164
|
-
|
|
165
|
+
private readonly getAuthHeadersCallback;
|
|
166
|
+
constructor(options: ShipClientOptions & {
|
|
167
|
+
getAuthHeaders: () => Record<string, string>;
|
|
168
|
+
});
|
|
165
169
|
/**
|
|
166
170
|
* Transfer events to another client (clean intentional API)
|
|
167
171
|
*/
|
|
@@ -171,13 +175,9 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
171
175
|
*/
|
|
172
176
|
private request;
|
|
173
177
|
/**
|
|
174
|
-
* Generate auth headers
|
|
178
|
+
* Generate auth headers from Ship instance callback
|
|
175
179
|
*/
|
|
176
180
|
private getAuthHeaders;
|
|
177
|
-
/**
|
|
178
|
-
* Check if credentials are needed
|
|
179
|
-
*/
|
|
180
|
-
private needsCredentials;
|
|
181
181
|
/**
|
|
182
182
|
* Safely clone response for events
|
|
183
183
|
*/
|
|
@@ -236,7 +236,7 @@ declare class ApiHttp extends SimpleEvents {
|
|
|
236
236
|
* @file Ship SDK resource implementations for deployments, domains, and accounts.
|
|
237
237
|
*/
|
|
238
238
|
|
|
239
|
-
declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]
|
|
239
|
+
declare function createDeploymentResource(getApi: () => ApiHttp, clientDefaults?: ShipClientOptions, ensureInit?: () => Promise<void>, processInput?: (input: DeployInput, options: DeploymentOptions) => Promise<StaticFile[]>, hasAuth?: () => boolean): DeploymentResource;
|
|
240
240
|
declare function createDomainResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): DomainResource;
|
|
241
241
|
declare function createAccountResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): AccountResource;
|
|
242
242
|
declare function createTokenResource(getApi: () => ApiHttp, ensureInit?: () => Promise<void>): TokenResource;
|
|
@@ -252,6 +252,8 @@ declare abstract class Ship$1 {
|
|
|
252
252
|
protected readonly clientOptions: ShipClientOptions;
|
|
253
253
|
protected initPromise: Promise<void> | null;
|
|
254
254
|
protected _config: ConfigResponse | null;
|
|
255
|
+
private auth;
|
|
256
|
+
private readonly authHeadersCallback;
|
|
255
257
|
protected _deployments: DeploymentResource;
|
|
256
258
|
protected _domains: DomainResource;
|
|
257
259
|
protected _account: AccountResource;
|
|
@@ -315,6 +317,30 @@ declare abstract class Ship$1 {
|
|
|
315
317
|
* @protected
|
|
316
318
|
*/
|
|
317
319
|
protected replaceHttpClient(newClient: ApiHttp): void;
|
|
320
|
+
/**
|
|
321
|
+
* Sets the deploy token for authentication.
|
|
322
|
+
* This will override any previously set API key or deploy token.
|
|
323
|
+
* @param token The deploy token (format: token-<64-char-hex>)
|
|
324
|
+
*/
|
|
325
|
+
setDeployToken(token: string): void;
|
|
326
|
+
/**
|
|
327
|
+
* Sets the API key for authentication.
|
|
328
|
+
* This will override any previously set API key or deploy token.
|
|
329
|
+
* @param key The API key (format: ship-<64-char-hex>)
|
|
330
|
+
*/
|
|
331
|
+
setApiKey(key: string): void;
|
|
332
|
+
/**
|
|
333
|
+
* Generate authorization headers based on current auth state
|
|
334
|
+
* Called dynamically on each request to ensure latest credentials are used
|
|
335
|
+
* @private
|
|
336
|
+
*/
|
|
337
|
+
private getAuthHeaders;
|
|
338
|
+
/**
|
|
339
|
+
* Check if authentication credentials are configured
|
|
340
|
+
* Used by resources to fail fast if auth is required
|
|
341
|
+
* @private
|
|
342
|
+
*/
|
|
343
|
+
private hasAuth;
|
|
318
344
|
}
|
|
319
345
|
|
|
320
346
|
/**
|
|
@@ -378,6 +404,35 @@ declare const JUNK_DIRECTORIES: readonly ["__MACOSX", ".Trashes", ".fseventsd",
|
|
|
378
404
|
*
|
|
379
405
|
* @param filePaths - An array of file path strings to filter
|
|
380
406
|
* @returns A new array containing only non-junk file paths
|
|
407
|
+
*
|
|
408
|
+
* @example
|
|
409
|
+
* ```typescript
|
|
410
|
+
* import { filterJunk } from '@shipstatic/ship';
|
|
411
|
+
*
|
|
412
|
+
* // Filter an array of file paths
|
|
413
|
+
* const paths = ['index.html', '.DS_Store', '__MACOSX/file.txt', 'app.js'];
|
|
414
|
+
* const clean = filterJunk(paths);
|
|
415
|
+
* // Result: ['index.html', 'app.js']
|
|
416
|
+
* ```
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```typescript
|
|
420
|
+
* // Use with browser File objects
|
|
421
|
+
* import { filterJunk } from '@shipstatic/ship';
|
|
422
|
+
*
|
|
423
|
+
* const files: File[] = [...]; // From input or drag-drop
|
|
424
|
+
*
|
|
425
|
+
* // Extract paths from File objects
|
|
426
|
+
* const filePaths = files.map(f => f.webkitRelativePath || f.name);
|
|
427
|
+
*
|
|
428
|
+
* // Filter out junk paths
|
|
429
|
+
* const validPaths = new Set(filterJunk(filePaths));
|
|
430
|
+
*
|
|
431
|
+
* // Filter the original File array
|
|
432
|
+
* const validFiles = files.filter(f =>
|
|
433
|
+
* validPaths.has(f.webkitRelativePath || f.name)
|
|
434
|
+
* );
|
|
435
|
+
* ```
|
|
381
436
|
*/
|
|
382
437
|
declare function filterJunk(filePaths: string[]): string[];
|
|
383
438
|
|
|
@@ -602,4 +657,4 @@ declare class Ship extends Ship$1 {
|
|
|
602
657
|
protected processInput(input: DeployInput, options: DeploymentOptions): Promise<StaticFile[]>;
|
|
603
658
|
}
|
|
604
659
|
|
|
605
|
-
export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, FILE_VALIDATION_STATUS, type FileValidationResult, type FileValidationStatus, JUNK_DIRECTORIES, type MD5Result, type
|
|
660
|
+
export { type ApiDeployOptions, ApiHttp, type Config, type DeployFile, type DeploymentOptions, type ExecutionEnvironment, FILE_VALIDATION_STATUS, type FileValidationResult, type FileValidationStatus, JUNK_DIRECTORIES, type MD5Result, type ProgressInfo, Ship, type ShipClientOptions, type ShipEvents, type ValidatableFile, type ValidationError, __setTestEnvironment, allValidFilesReady, calculateMD5, createAccountResource, createDeploymentResource, createDomainResource, createTokenResource, Ship as default, filterJunk, formatFileSize, getCurrentConfig, getENV, getValidFiles, loadConfig, mergeDeployOptions, optimizeDeployPaths, pluralize, processFilesForBrowser, resolveConfig, setConfig as setPlatformConfig, validateFiles };
|