ship-em 0.1.0 → 0.2.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/dist/lib.d.ts ADDED
@@ -0,0 +1,252 @@
1
+ type Framework = 'nextjs' | 'vite-react' | 'vite-vue' | 'vite-svelte' | 'astro' | 'sveltekit' | 'remix' | 'nuxt' | 'gatsby' | 'create-react-app' | 'hono' | 'static-html' | 'unknown';
2
+ type DeployTarget = 'cloudflare-pages' | 'cloudflare-workers';
3
+ type ServerType = 'static' | 'serverless' | 'server';
4
+ interface EnvVar {
5
+ name: string;
6
+ description: string;
7
+ required: boolean;
8
+ autoProvision?: boolean;
9
+ value?: string;
10
+ }
11
+ interface ProjectConfig {
12
+ name: string;
13
+ framework: Framework;
14
+ buildCommand: string;
15
+ outputDirectory: string;
16
+ installCommand: string;
17
+ serverType: ServerType;
18
+ nodeVersion?: string;
19
+ pythonVersion?: string;
20
+ envVars: EnvVar[];
21
+ deployTarget: DeployTarget;
22
+ detectedAt: string;
23
+ aiAnalysis?: string;
24
+ }
25
+ interface DeploymentState {
26
+ projectName: string;
27
+ deploymentId: string;
28
+ url: string;
29
+ cloudflareProjectName?: string;
30
+ cloudflareAccountId?: string;
31
+ deployTarget: DeployTarget;
32
+ deployedAt: string;
33
+ status: 'success' | 'building' | 'failed';
34
+ }
35
+ interface DeployRecord {
36
+ timestamp: string;
37
+ url: string;
38
+ duration: number;
39
+ files: number;
40
+ size: string;
41
+ framework: string;
42
+ }
43
+ interface PreviewRecord {
44
+ branch: string;
45
+ url: string;
46
+ deploymentId: string;
47
+ createdAt: string;
48
+ status: 'success' | 'building' | 'failed';
49
+ }
50
+ interface ShipemConfig {
51
+ project?: ProjectConfig;
52
+ deployment?: DeploymentState;
53
+ deployments?: DeployRecord[];
54
+ previews?: PreviewRecord[];
55
+ }
56
+ interface CloudflareCredentials {
57
+ apiToken: string;
58
+ accountId: string;
59
+ }
60
+ interface AuthConfig {
61
+ cloudflare?: CloudflareCredentials;
62
+ sessionToken?: string;
63
+ }
64
+
65
+ interface MonorepoInfo {
66
+ type: 'turbo' | 'nx' | 'pnpm-workspaces' | 'npm-workspaces' | 'yarn-workspaces';
67
+ packages: string[];
68
+ }
69
+ interface ScanResult {
70
+ framework: Framework;
71
+ buildCommand: string;
72
+ outputDirectory: string;
73
+ installCommand: string;
74
+ serverType: ServerType;
75
+ deployTarget: DeployTarget;
76
+ nodeVersion?: string;
77
+ pythonVersion?: string;
78
+ envVars: EnvVar[];
79
+ projectName: string;
80
+ confidence: number;
81
+ files: string[];
82
+ notes?: string;
83
+ monorepo?: MonorepoInfo;
84
+ }
85
+ declare function scanProject(cwd?: string): ScanResult;
86
+ /** Detect if this is a monorepo and list its packages. */
87
+ declare function detectMonorepo(cwd: string): MonorepoInfo | undefined;
88
+
89
+ declare const SHIPEM_API_URL: string;
90
+ declare function getCloudflareCredentials(): {
91
+ apiToken: string;
92
+ accountId: string;
93
+ } | null;
94
+ declare function getSessionToken(): string | null;
95
+ declare function readProjectConfig(cwd?: string): ShipemConfig;
96
+ declare function writeProjectConfig(config: ShipemConfig, cwd?: string): void;
97
+
98
+ interface BuildResult {
99
+ success: boolean;
100
+ outputDirectory: string;
101
+ durationMs: number;
102
+ error?: string;
103
+ }
104
+ declare function buildProject(config: ProjectConfig, cwd?: string): Promise<BuildResult>;
105
+
106
+ interface CFProject {
107
+ id: string;
108
+ name: string;
109
+ subdomain: string;
110
+ domains: string[];
111
+ latest_deployment?: {
112
+ id: string;
113
+ url: string;
114
+ latest_stage: {
115
+ name: string;
116
+ status: string;
117
+ };
118
+ };
119
+ }
120
+ interface CFDeployment {
121
+ id: string;
122
+ url: string;
123
+ latest_stage: {
124
+ name: string;
125
+ status: string;
126
+ };
127
+ stages: Array<{
128
+ name: string;
129
+ status: string;
130
+ started_on: string | null;
131
+ ended_on: string | null;
132
+ }>;
133
+ }
134
+ declare class CloudflarePages {
135
+ private client;
136
+ private accountId;
137
+ constructor(apiToken: string, accountId: string);
138
+ getOrCreateProject(projectName: string, config: ProjectConfig): Promise<CFProject>;
139
+ setEnvironmentVariables(projectName: string, envVars: Record<string, string>): Promise<void>;
140
+ deployDirectory(projectName: string, outputDir: string, cwd?: string): Promise<{
141
+ deployment: CFDeployment;
142
+ fileCount: number;
143
+ totalBytes: number;
144
+ }>;
145
+ deployBranch(projectName: string, outputDir: string, branch: string, cwd?: string): Promise<{
146
+ deployment: CFDeployment;
147
+ fileCount: number;
148
+ totalBytes: number;
149
+ }>;
150
+ waitForDeployment(projectName: string, deploymentId: string, timeoutMs?: number): Promise<CFDeployment>;
151
+ getDeploymentStatus(projectName: string, deploymentId: string): Promise<CFDeployment | null>;
152
+ getDeploymentLogs(projectName: string, deploymentId: string): Promise<string[]>;
153
+ deleteProject(projectName: string): Promise<void>;
154
+ getProjectUrl(projectName: string): string;
155
+ getDashboardUrl(projectName: string): string;
156
+ validateCredentials(): Promise<{
157
+ valid: boolean;
158
+ accountName?: string;
159
+ }>;
160
+ }
161
+ declare function sanitizeProjectName(name: string): string;
162
+
163
+ /**
164
+ * Error hierarchy for Shipem CLI.
165
+ *
166
+ * All Shipem errors extend ShipemError so callers can distinguish
167
+ * between expected operational errors and unexpected bugs.
168
+ */
169
+ declare class ShipemError extends Error {
170
+ /** Machine-readable error code for programmatic consumers (--json mode). */
171
+ readonly code: string;
172
+ /** Suggested exit code: 1 = user error, 2 = system/infra error. */
173
+ readonly exitCode: number;
174
+ constructor(message: string, opts?: {
175
+ code: string;
176
+ exitCode?: number;
177
+ cause?: unknown;
178
+ });
179
+ }
180
+ /** Network-level failures (DNS, timeout, connection refused). */
181
+ declare class NetworkError extends ShipemError {
182
+ constructor(message: string, opts?: {
183
+ cause?: unknown;
184
+ });
185
+ }
186
+ /** Authentication / authorization failures. */
187
+ declare class AuthError extends ShipemError {
188
+ constructor(message: string, opts?: {
189
+ cause?: unknown;
190
+ });
191
+ }
192
+ /** Deployment failures (Cloudflare API, Fly.io, upload errors). */
193
+ declare class DeployError extends ShipemError {
194
+ constructor(message: string, opts?: {
195
+ cause?: unknown;
196
+ });
197
+ }
198
+ /** Build-step failures (install or compile). */
199
+ declare class BuildError extends ShipemError {
200
+ constructor(message: string, opts?: {
201
+ cause?: unknown;
202
+ });
203
+ }
204
+ /** Configuration errors (missing config, bad env vars, corrupt files). */
205
+ declare class ConfigError extends ShipemError {
206
+ constructor(message: string, opts?: {
207
+ cause?: unknown;
208
+ });
209
+ }
210
+
211
+ /** Run the fix logic on a build error. Returns actions taken. */
212
+ declare function runFixHeuristics(errorOutput: string, cwd: string, config: ProjectConfig): Promise<{
213
+ actions: string[];
214
+ fixed: boolean;
215
+ }>;
216
+
217
+ /** Scan source files for env var references. */
218
+ declare function scanSourceForEnvVars(cwd: string): string[];
219
+ /** Read env vars from .env file (keys only). */
220
+ declare function readEnvFile(cwd: string): Set<string>;
221
+
222
+ interface FrameworkChoice {
223
+ name: string;
224
+ value: string;
225
+ createCmd: string[];
226
+ keywords: string[];
227
+ }
228
+ declare const FRAMEWORKS: FrameworkChoice[];
229
+ /** Match description to best framework using keyword scoring. */
230
+ declare function matchFramework(description: string): FrameworkChoice;
231
+ /** Generate a project name from description. */
232
+ declare function generateProjectName(description: string): string;
233
+
234
+ /** Detect the current git branch. */
235
+ declare function getCurrentBranch(): Promise<string>;
236
+ /** Sanitise a git branch name into a valid CF Pages branch slug. */
237
+ declare function sanitizeBranchName(branch: string): string;
238
+
239
+ interface Template {
240
+ name: string;
241
+ description: string;
242
+ framework: string;
243
+ createCmd: string[];
244
+ postScaffold?: string[];
245
+ }
246
+ declare const TEMPLATES: Template[];
247
+ /** Look up a template by name (case-insensitive). */
248
+ declare function getTemplate(name: string): Template | undefined;
249
+ /** List all available template names. */
250
+ declare function getTemplateNames(): string[];
251
+
252
+ export { type AuthConfig, AuthError, BuildError, type BuildResult, type CloudflareCredentials, CloudflarePages, ConfigError, DeployError, type DeployRecord, type DeployTarget, type DeploymentState, type EnvVar, FRAMEWORKS, type Framework, type FrameworkChoice, type MonorepoInfo, NetworkError, type PreviewRecord, type ProjectConfig, SHIPEM_API_URL, type ServerType, type ShipemConfig, ShipemError, TEMPLATES, type Template, buildProject, detectMonorepo, generateProjectName, getCloudflareCredentials, getCurrentBranch, getSessionToken, getTemplate, getTemplateNames, matchFramework, readEnvFile, readProjectConfig, runFixHeuristics, sanitizeBranchName, sanitizeProjectName, scanProject, scanSourceForEnvVars, writeProjectConfig };