@umituz/web-cloudflare 1.4.9 → 1.4.11
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-cloudflare",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.11",
|
|
4
4
|
"description": "Comprehensive Cloudflare Workers & Pages integration with config-based patterns, middleware, router, workflows, and AI (Patch-only versioning: only z in x.y.z increments)",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Pages Domain
|
|
3
3
|
* Cloudflare Pages deployment and management
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
//
|
|
7
|
-
export
|
|
6
|
+
// Entities
|
|
7
|
+
export * from './entities';
|
|
8
8
|
|
|
9
9
|
// Types
|
|
10
|
-
export
|
|
11
|
-
IPagesService,
|
|
12
|
-
} from './types';
|
|
10
|
+
export * from './types';
|
|
13
11
|
|
|
14
|
-
//
|
|
15
|
-
export
|
|
16
|
-
PagesProject,
|
|
17
|
-
PagesDeployment,
|
|
18
|
-
PagesDeployOptions,
|
|
19
|
-
PagesFunction,
|
|
20
|
-
PagesDeploymentResult,
|
|
21
|
-
} from './entities';
|
|
12
|
+
// Services
|
|
13
|
+
export * from './services';
|
|
@@ -34,21 +34,53 @@ export class PagesService implements IPagesService {
|
|
|
34
34
|
compatibilityDate?: string;
|
|
35
35
|
}
|
|
36
36
|
): Promise<{ success: boolean; data?: PagesProject; error?: string }> {
|
|
37
|
-
|
|
37
|
+
const args = ['project', 'create', projectName];
|
|
38
|
+
if (options?.productionBranch) {
|
|
39
|
+
args.push('--production-branch', options.productionBranch);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const result = this.executeWranglerPages(args);
|
|
43
|
+
if (result.success) {
|
|
44
|
+
return {
|
|
45
|
+
success: true,
|
|
46
|
+
data: {
|
|
47
|
+
name: projectName,
|
|
48
|
+
production_branch: options?.productionBranch,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { success: false, error: result.stderr };
|
|
38
53
|
}
|
|
39
54
|
|
|
40
55
|
/**
|
|
41
56
|
* List all Pages projects
|
|
42
57
|
*/
|
|
43
58
|
async listProjects(): Promise<{ success: boolean; data?: PagesProject[]; error?: string }> {
|
|
44
|
-
|
|
59
|
+
const result = this.executeWranglerPages(['project', 'list']);
|
|
60
|
+
if (result.success) {
|
|
61
|
+
// Parse output to get project list
|
|
62
|
+
try {
|
|
63
|
+
const projects = this.parseProjectsList(result.stdout);
|
|
64
|
+
return { success: true, data: projects };
|
|
65
|
+
} catch {
|
|
66
|
+
return { success: true, data: [] };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return { success: false, error: result.stderr };
|
|
45
70
|
}
|
|
46
71
|
|
|
47
72
|
/**
|
|
48
73
|
* Get project details
|
|
49
74
|
*/
|
|
50
75
|
async getProject(projectName: string): Promise<{ success: boolean; data?: PagesProject; error?: string }> {
|
|
51
|
-
|
|
76
|
+
const result = this.executeWranglerPages(['project', 'view', projectName]);
|
|
77
|
+
if (result.success) {
|
|
78
|
+
return {
|
|
79
|
+
success: true,
|
|
80
|
+
data: { name: projectName },
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return { success: false, error: result.stderr };
|
|
52
84
|
}
|
|
53
85
|
|
|
54
86
|
/**
|
|
@@ -57,7 +89,39 @@ export class PagesService implements IPagesService {
|
|
|
57
89
|
async deploy(
|
|
58
90
|
options: PagesDeployOptions
|
|
59
91
|
): Promise<{ success: boolean; data?: PagesDeploymentResult; error?: string }> {
|
|
60
|
-
|
|
92
|
+
const args = ['deploy', options.directory || 'dist', '--project-name', options.projectName];
|
|
93
|
+
|
|
94
|
+
if (options.branch) {
|
|
95
|
+
args.push('--branch', options.branch);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (options.environment === 'preview') {
|
|
99
|
+
args.push('--branch', `preview-${Date.now()}`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Add environment variables
|
|
103
|
+
if (options.vars && Object.keys(options.vars).length > 0) {
|
|
104
|
+
Object.entries(options.vars).forEach(([key, value]) => {
|
|
105
|
+
args.push('--var', `${key}:${value}`);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const result = this.executeWranglerPages(args);
|
|
110
|
+
if (result.success) {
|
|
111
|
+
const url = this.extractDeploymentUrl(result.stdout);
|
|
112
|
+
return {
|
|
113
|
+
success: true,
|
|
114
|
+
data: {
|
|
115
|
+
deployment: {
|
|
116
|
+
id: Date.now().toString(),
|
|
117
|
+
project: options.projectName,
|
|
118
|
+
url: url || '',
|
|
119
|
+
},
|
|
120
|
+
url,
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return { success: false, error: result.stderr };
|
|
61
125
|
}
|
|
62
126
|
|
|
63
127
|
/**
|
|
@@ -71,7 +135,23 @@ export class PagesService implements IPagesService {
|
|
|
71
135
|
compatibilityFlags?: string[];
|
|
72
136
|
}
|
|
73
137
|
): Promise<{ success: boolean; data?: PagesFunction; error?: string }> {
|
|
74
|
-
|
|
138
|
+
const args = ['function', 'create', projectName, functionName];
|
|
139
|
+
|
|
140
|
+
if (options?.compatibilityDate) {
|
|
141
|
+
args.push('--compatibility-date', options.compatibilityDate);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const result = this.executeWranglerPages(args);
|
|
145
|
+
if (result.success) {
|
|
146
|
+
return {
|
|
147
|
+
success: true,
|
|
148
|
+
data: {
|
|
149
|
+
name: functionName,
|
|
150
|
+
compatibilityDate: options?.compatibilityDate,
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
return { success: false, error: result.stderr };
|
|
75
155
|
}
|
|
76
156
|
|
|
77
157
|
/**
|
|
@@ -80,7 +160,11 @@ export class PagesService implements IPagesService {
|
|
|
80
160
|
async listDeployments(
|
|
81
161
|
projectName: string
|
|
82
162
|
): Promise<{ success: boolean; data?: PagesDeployment[]; error?: string }> {
|
|
83
|
-
|
|
163
|
+
const result = this.executeWranglerPages(['deployment', 'list', '--project-name', projectName]);
|
|
164
|
+
if (result.success) {
|
|
165
|
+
return { success: true, data: [] };
|
|
166
|
+
}
|
|
167
|
+
return { success: false, error: result.stderr };
|
|
84
168
|
}
|
|
85
169
|
|
|
86
170
|
/**
|
|
@@ -90,7 +174,24 @@ export class PagesService implements IPagesService {
|
|
|
90
174
|
projectName: string,
|
|
91
175
|
deploymentId: string
|
|
92
176
|
): Promise<{ success: boolean; data?: PagesDeployment; error?: string }> {
|
|
93
|
-
|
|
177
|
+
const result = this.executeWranglerPages([
|
|
178
|
+
'deployment',
|
|
179
|
+
'view',
|
|
180
|
+
deploymentId,
|
|
181
|
+
'--project-name',
|
|
182
|
+
projectName,
|
|
183
|
+
]);
|
|
184
|
+
if (result.success) {
|
|
185
|
+
return {
|
|
186
|
+
success: true,
|
|
187
|
+
data: {
|
|
188
|
+
id: deploymentId,
|
|
189
|
+
project: projectName,
|
|
190
|
+
url: '',
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return { success: false, error: result.stderr };
|
|
94
195
|
}
|
|
95
196
|
|
|
96
197
|
/**
|
|
@@ -100,7 +201,17 @@ export class PagesService implements IPagesService {
|
|
|
100
201
|
projectName: string,
|
|
101
202
|
deploymentId: string
|
|
102
203
|
): Promise<{ success: boolean; error?: string }> {
|
|
103
|
-
|
|
204
|
+
const result = this.executeWranglerPages([
|
|
205
|
+
'deployment',
|
|
206
|
+
'delete',
|
|
207
|
+
deploymentId,
|
|
208
|
+
'--project-name',
|
|
209
|
+
projectName,
|
|
210
|
+
]);
|
|
211
|
+
if (result.success) {
|
|
212
|
+
return { success: true };
|
|
213
|
+
}
|
|
214
|
+
return { success: false, error: result.stderr };
|
|
104
215
|
}
|
|
105
216
|
|
|
106
217
|
/**
|
|
@@ -132,12 +243,29 @@ export class PagesService implements IPagesService {
|
|
|
132
243
|
}
|
|
133
244
|
}
|
|
134
245
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
246
|
+
/**
|
|
247
|
+
* Parse projects list output
|
|
248
|
+
*/
|
|
249
|
+
private parseProjectsList(stdout: string): PagesProject[] {
|
|
250
|
+
const projects: PagesProject[] = [];
|
|
251
|
+
const lines = stdout.split('\n');
|
|
252
|
+
for (const line of lines) {
|
|
253
|
+
if (line.includes('│')) {
|
|
254
|
+
const parts = line.split('│').map((s) => s.trim());
|
|
255
|
+
if (parts.length >= 2 && parts[1]) {
|
|
256
|
+
projects.push({ name: parts[1] });
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return projects;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Extract deployment URL from wrangler output
|
|
265
|
+
*/
|
|
266
|
+
private extractDeploymentUrl(stdout: string): string | undefined {
|
|
267
|
+
const urlMatch = stdout.match(/https?:\/\/[^\s]+\.pages\.dev[^\s]*/);
|
|
268
|
+
return urlMatch ? urlMatch[0] : undefined;
|
|
141
269
|
}
|
|
142
270
|
}
|
|
143
271
|
|