@jxrstudios/jxr 1.2.17 → 1.2.19
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/bin/jxr.js +15 -87
- package/package.json +1 -1
- package/src/deployer.ts +130 -2
- package/dist/deployer.d.ts +0 -66
- package/dist/deployer.d.ts.map +0 -1
- package/dist/deployer.js +0 -163
- package/dist/deployer.js.map +0 -1
- package/dist/enhanced-transpiler.d.ts +0 -36
- package/dist/enhanced-transpiler.d.ts.map +0 -1
- package/dist/enhanced-transpiler.js +0 -272
- package/dist/enhanced-transpiler.js.map +0 -1
- package/dist/entry-point-detection.d.ts +0 -22
- package/dist/entry-point-detection.d.ts.map +0 -1
- package/dist/entry-point-detection.js +0 -415
- package/dist/entry-point-detection.js.map +0 -1
- package/dist/index.d.ts +0 -72
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2217
- package/dist/index.js.map +0 -1
- package/dist/jxr-server-manager.d.ts +0 -32
- package/dist/jxr-server-manager.d.ts.map +0 -1
- package/dist/jxr-server-manager.js +0 -353
- package/dist/jxr-server-manager.js.map +0 -1
- package/dist/module-resolver.d.ts +0 -115
- package/dist/module-resolver.d.ts.map +0 -1
- package/dist/module-resolver.js +0 -430
- package/dist/module-resolver.js.map +0 -1
- package/dist/moq-transport.d.ts +0 -96
- package/dist/moq-transport.d.ts.map +0 -1
- package/dist/moq-transport.js +0 -188
- package/dist/moq-transport.js.map +0 -1
- package/dist/runtime.d.ts +0 -70
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js +0 -150
- package/dist/runtime.js.map +0 -1
- package/dist/web-crypto.d.ts +0 -77
- package/dist/web-crypto.d.ts.map +0 -1
- package/dist/web-crypto.js +0 -186
- package/dist/web-crypto.js.map +0 -1
- package/dist/worker-pool.d.ts +0 -83
- package/dist/worker-pool.d.ts.map +0 -1
- package/dist/worker-pool.js +0 -238
- package/dist/worker-pool.js.map +0 -1
package/bin/jxr.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { JXRServerManager, JXRDeployer } from "../
|
|
2
|
+
import { JXRServerManager, JXRDeployer } from "../dist/index.js";
|
|
3
3
|
|
|
4
4
|
import { mkdir, writeFile, cp, readdir } from "fs/promises";
|
|
5
5
|
import { existsSync } from "fs";
|
|
@@ -275,75 +275,19 @@ if (command === "init") {
|
|
|
275
275
|
console.log(`🚀 Deploying to ${target === "auto" ? "auto-detected platform" : target}...`);
|
|
276
276
|
|
|
277
277
|
try {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
let buildDir = path.join(projectPath, "dist");
|
|
283
|
-
if (!fs.existsSync(buildDir)) {
|
|
284
|
-
buildDir = path.join(projectPath, "build");
|
|
285
|
-
}
|
|
286
|
-
if (!fs.existsSync(buildDir)) {
|
|
287
|
-
buildDir = path.join(projectPath, "out");
|
|
288
|
-
}
|
|
289
|
-
if (!fs.existsSync(buildDir)) {
|
|
290
|
-
// Look for any directory with index.html
|
|
291
|
-
const dirs = fs.readdirSync(projectPath, { withFileTypes: true })
|
|
292
|
-
.filter(d => d.isDirectory() && !d.name.startsWith(".") && !d.name === "node_modules")
|
|
293
|
-
.map(d => path.join(projectPath, d.name));
|
|
294
|
-
|
|
295
|
-
for (const dir of dirs) {
|
|
296
|
-
if (fs.existsSync(path.join(dir, "index.html"))) {
|
|
297
|
-
buildDir = dir;
|
|
298
|
-
break;
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (!fs.existsSync(buildDir)) {
|
|
304
|
-
console.error("❌ No build output found. Run 'jxr build' first.");
|
|
305
|
-
process.exit(1);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Check for jxr-manifest.json for verification
|
|
309
|
-
const manifestPath = path.join(buildDir, "jxr-manifest.json");
|
|
310
|
-
if (fs.existsSync(manifestPath)) {
|
|
311
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, "utf-8"));
|
|
312
|
-
console.log(`📋 Build manifest: ${manifest.platform} platform`);
|
|
313
|
-
console.log(` Files: ${manifest.files.length}`);
|
|
314
|
-
console.log(` Signed: ${manifest.algorithm}`);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
// Detect if running on Cloudflare Pages
|
|
318
|
-
const isCloudflarePages = process.env.CF_PAGES === "1" || process.env.CF_PAGES_URL !== undefined;
|
|
319
|
-
|
|
320
|
-
if (target === "cloudflare" || target === "auto" && isCloudflarePages) {
|
|
321
|
-
console.log("☁️ Deploying to Cloudflare Pages...");
|
|
278
|
+
// Use JXRDeployer for Cloudflare Pages deployment
|
|
279
|
+
if (target === "cloudflare" || target === "auto") {
|
|
280
|
+
const deployer = new JXRDeployer(process.env.JXR_API_KEY || '', process.env.JXR_PROJECT_ID);
|
|
281
|
+
const result = await deployer.deployToCloudflarePages(projectPath, { environment: env });
|
|
322
282
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const pkg = JSON.parse(fs.readFileSync(path.join(projectPath, "package.json"), "utf-8"));
|
|
328
|
-
projectName = pkg.name;
|
|
329
|
-
} catch {
|
|
330
|
-
projectName = path.basename(path.resolve(projectPath));
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// On Cloudflare Pages, the build output is automatically deployed
|
|
335
|
-
// We just need to ensure it's in the right location
|
|
336
|
-
console.log(` Project: ${projectName}`);
|
|
337
|
-
console.log(` Environment: ${env}`);
|
|
338
|
-
|
|
339
|
-
if (isCloudflarePages) {
|
|
340
|
-
console.log(` URL: https://${projectName}.app.jxrstudios.online`);
|
|
341
|
-
console.log("✅ Deployment ready for Cloudflare Pages");
|
|
342
|
-
console.log(" The build output will be deployed automatically.");
|
|
283
|
+
if (result.success) {
|
|
284
|
+
console.log("✅ Deployed successfully!");
|
|
285
|
+
console.log(` URL: ${result.url}`);
|
|
286
|
+
result.logs.forEach(log => console.log(` ${log}`));
|
|
343
287
|
} else {
|
|
344
|
-
|
|
345
|
-
console.
|
|
346
|
-
|
|
288
|
+
console.error("❌ Deploy failed");
|
|
289
|
+
result.logs.forEach(log => console.error(` ${log}`));
|
|
290
|
+
process.exit(1);
|
|
347
291
|
}
|
|
348
292
|
|
|
349
293
|
} else if (target === "deno") {
|
|
@@ -355,25 +299,9 @@ if (command === "init") {
|
|
|
355
299
|
console.log(" Copy the dist/ folder to your Node.js server");
|
|
356
300
|
|
|
357
301
|
} else {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
console.error(" Get your key at: https://jxrstudios.online/dashboard");
|
|
362
|
-
process.exit(1);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
const deployer = new JXRDeployer(process.env.JXR_API_KEY, process.env.JXR_PROJECT_ID);
|
|
366
|
-
const result = await deployer.deploy(buildDir, { environment: env });
|
|
367
|
-
|
|
368
|
-
if (result.success) {
|
|
369
|
-
console.log("✅ Deployed successfully!");
|
|
370
|
-
console.log(` URL: ${result.url}`);
|
|
371
|
-
result.logs.forEach(log => console.log(` ${log}`));
|
|
372
|
-
} else {
|
|
373
|
-
console.error("❌ Deploy failed");
|
|
374
|
-
result.logs.forEach(log => console.error(` ${log}`));
|
|
375
|
-
process.exit(1);
|
|
376
|
-
}
|
|
302
|
+
console.error(`❌ Unknown target: ${target}`);
|
|
303
|
+
console.error(" Supported: cloudflare, deno, node, auto");
|
|
304
|
+
process.exit(1);
|
|
377
305
|
}
|
|
378
306
|
|
|
379
307
|
} catch (err) {
|
package/package.json
CHANGED
package/src/deployer.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
import { readFile, readdir, stat } from "fs/promises";
|
|
8
8
|
import path from "path";
|
|
9
|
-
import { createWriteStream } from "fs";
|
|
9
|
+
import { createWriteStream, existsSync } from "fs";
|
|
10
10
|
import { spawn } from "child_process";
|
|
11
11
|
|
|
12
12
|
export interface DeployConfig {
|
|
@@ -43,6 +43,134 @@ export class JXRDeployer {
|
|
|
43
43
|
this.projectId = projectId || this.generateProjectId();
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Auto-detect build output directory
|
|
48
|
+
* Checks dist/, build/, out/, or any directory with index.html
|
|
49
|
+
*/
|
|
50
|
+
async detectBuildDir(projectPath: string = '.'): Promise<string | null> {
|
|
51
|
+
const possibleDirs = ['dist', 'build', 'out'];
|
|
52
|
+
|
|
53
|
+
// Check standard build directories
|
|
54
|
+
for (const dir of possibleDirs) {
|
|
55
|
+
const fullPath = path.resolve(projectPath, dir);
|
|
56
|
+
if (existsSync(fullPath)) {
|
|
57
|
+
// Verify it has index.html
|
|
58
|
+
if (existsSync(path.join(fullPath, 'index.html'))) {
|
|
59
|
+
return fullPath;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Search for any directory with index.html
|
|
65
|
+
try {
|
|
66
|
+
const entries = await readdir(projectPath, { withFileTypes: true });
|
|
67
|
+
for (const entry of entries) {
|
|
68
|
+
if (entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules') {
|
|
69
|
+
const dirPath = path.join(projectPath, entry.name);
|
|
70
|
+
if (existsSync(path.join(dirPath, 'index.html'))) {
|
|
71
|
+
return dirPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch {
|
|
76
|
+
// Ignore errors
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Detect if running on Cloudflare Pages
|
|
84
|
+
*/
|
|
85
|
+
isCloudflarePages(): boolean {
|
|
86
|
+
return process.env.CF_PAGES === '1' || !!process.env.CF_PAGES_URL;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Get project name from package.json or directory
|
|
91
|
+
*/
|
|
92
|
+
async getProjectName(projectPath: string = '.'): Promise<string> {
|
|
93
|
+
// Check CF_PAGES_PROJECT_NAME first
|
|
94
|
+
if (process.env.CF_PAGES_PROJECT_NAME) {
|
|
95
|
+
return process.env.CF_PAGES_PROJECT_NAME;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Try to read from package.json
|
|
99
|
+
try {
|
|
100
|
+
const pkgPath = path.join(projectPath, 'package.json');
|
|
101
|
+
const pkgContent = await readFile(pkgPath, 'utf-8');
|
|
102
|
+
const pkg = JSON.parse(pkgContent);
|
|
103
|
+
if (pkg.name) {
|
|
104
|
+
return pkg.name;
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
// Ignore errors
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Fall back to directory name
|
|
111
|
+
return path.basename(path.resolve(projectPath));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Deploy to Cloudflare Pages
|
|
116
|
+
*/
|
|
117
|
+
async deployToCloudflarePages(projectPath: string = '.', config: DeployConfig = {}): Promise<DeployResult> {
|
|
118
|
+
const logs: string[] = [];
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
// Auto-detect build directory
|
|
122
|
+
const buildDir = await this.detectBuildDir(projectPath);
|
|
123
|
+
if (!buildDir) {
|
|
124
|
+
throw new Error('No build output found. Run "jxr build" first.');
|
|
125
|
+
}
|
|
126
|
+
logs.push(`📁 Build directory: ${buildDir}`);
|
|
127
|
+
|
|
128
|
+
// Get project name
|
|
129
|
+
const projectName = await this.getProjectName(projectPath);
|
|
130
|
+
logs.push(`📦 Project: ${projectName}`);
|
|
131
|
+
|
|
132
|
+
// Check for manifest
|
|
133
|
+
const manifestPath = path.join(buildDir, 'jxr-manifest.json');
|
|
134
|
+
if (existsSync(manifestPath)) {
|
|
135
|
+
const manifest = JSON.parse(await readFile(manifestPath, 'utf-8'));
|
|
136
|
+
logs.push(`📋 Manifest: ${manifest.platform} platform, ${manifest.files?.length || 0} files`);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Determine URL
|
|
140
|
+
const env = config.environment || 'production';
|
|
141
|
+
const url = `https://${projectName}.app.jxrstudios.online`;
|
|
142
|
+
logs.push(`🌐 URL: ${url}`);
|
|
143
|
+
|
|
144
|
+
// If running on Cloudflare Pages, the deployment is automatic
|
|
145
|
+
if (this.isCloudflarePages()) {
|
|
146
|
+
logs.push('☁️ Cloudflare Pages auto-detected');
|
|
147
|
+
logs.push('✅ Deployment ready - build output will be deployed automatically');
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
success: true,
|
|
151
|
+
url,
|
|
152
|
+
deploymentId: `cf-pages-${Date.now()}`,
|
|
153
|
+
timestamp: new Date().toISOString(),
|
|
154
|
+
logs,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Manual deployment via JXR API
|
|
159
|
+
return await this.deploy(buildDir, { ...config, projectId: projectName });
|
|
160
|
+
|
|
161
|
+
} catch (error) {
|
|
162
|
+
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
163
|
+
logs.push(`❌ Error: ${errorMsg}`);
|
|
164
|
+
return {
|
|
165
|
+
success: false,
|
|
166
|
+
url: '',
|
|
167
|
+
deploymentId: '',
|
|
168
|
+
timestamp: new Date().toISOString(),
|
|
169
|
+
logs,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
46
174
|
/**
|
|
47
175
|
* Deploy the current project to JXR infrastructure
|
|
48
176
|
*/
|
|
@@ -69,7 +197,7 @@ export class JXRDeployer {
|
|
|
69
197
|
logs.push(`☁️ Uploaded to JXR`);
|
|
70
198
|
|
|
71
199
|
// Get deployment URL
|
|
72
|
-
const url = `https://${pid}.
|
|
200
|
+
const url = `https://${pid}.app.jxrstudios.online`;
|
|
73
201
|
logs.push(`🌐 Live at: ${url}`);
|
|
74
202
|
|
|
75
203
|
return {
|
package/dist/deployer.d.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JXR.js — Wranglerless Deployer
|
|
3
|
-
* Deploy projects to JXR Studios' Cloudflare infrastructure without wrangler.
|
|
4
|
-
* Users only need a JXR API key - no Cloudflare account required.
|
|
5
|
-
*/
|
|
6
|
-
export interface DeployConfig {
|
|
7
|
-
projectId?: string;
|
|
8
|
-
environment?: 'production' | 'staging' | 'preview';
|
|
9
|
-
branch?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface DeployResult {
|
|
12
|
-
success: boolean;
|
|
13
|
-
url: string;
|
|
14
|
-
deploymentId: string;
|
|
15
|
-
timestamp: string;
|
|
16
|
-
logs: string[];
|
|
17
|
-
}
|
|
18
|
-
export interface DeploymentStatus {
|
|
19
|
-
status: 'pending' | 'building' | 'deployed' | 'failed';
|
|
20
|
-
progress: number;
|
|
21
|
-
url?: string;
|
|
22
|
-
error?: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* JXRDeployer — Deploy to JXR Cloudflare infrastructure
|
|
26
|
-
* No wrangler config needed. Just your JXR API key.
|
|
27
|
-
*/
|
|
28
|
-
export declare class JXRDeployer {
|
|
29
|
-
private apiKey;
|
|
30
|
-
private projectId;
|
|
31
|
-
constructor(apiKey: string, projectId?: string);
|
|
32
|
-
/**
|
|
33
|
-
* Deploy the current project to JXR infrastructure
|
|
34
|
-
*/
|
|
35
|
-
deploy(projectPath: string, config?: DeployConfig): Promise<DeployResult>;
|
|
36
|
-
/**
|
|
37
|
-
* Create a tarball of the build directory
|
|
38
|
-
*/
|
|
39
|
-
private createTarball;
|
|
40
|
-
/**
|
|
41
|
-
* Upload tarball to JXR API
|
|
42
|
-
*/
|
|
43
|
-
private uploadTarball;
|
|
44
|
-
/**
|
|
45
|
-
* Get deployment status
|
|
46
|
-
*/
|
|
47
|
-
getStatus(deploymentId: string): Promise<DeploymentStatus>;
|
|
48
|
-
/**
|
|
49
|
-
* List all deployments for a project
|
|
50
|
-
*/
|
|
51
|
-
listDeployments(projectId?: string): Promise<Array<{
|
|
52
|
-
id: string;
|
|
53
|
-
url: string;
|
|
54
|
-
environment: string;
|
|
55
|
-
createdAt: string;
|
|
56
|
-
status: string;
|
|
57
|
-
}>>;
|
|
58
|
-
/**
|
|
59
|
-
* Rollback to a previous deployment
|
|
60
|
-
*/
|
|
61
|
-
rollback(deploymentId: string): Promise<DeployResult>;
|
|
62
|
-
private generateProjectId;
|
|
63
|
-
}
|
|
64
|
-
/** Global deployer singleton */
|
|
65
|
-
export declare const jxrDeployer: JXRDeployer;
|
|
66
|
-
//# sourceMappingURL=deployer.d.ts.map
|
package/dist/deployer.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.d.ts","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IACvD,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;gBAEd,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;IAK9C;;OAEG;IACG,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,GAAE,YAAiB,GAAG,OAAO,CAAC,YAAY,CAAC;IA+CnF;;OAEG;YACW,aAAa;IAkB3B;;OAEG;YACW,aAAa;IAgC3B;;OAEG;IACG,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAchE;;OAEG;IACG,eAAe,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QACvD,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,EAAE,MAAM,CAAC;QACZ,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC,CAAC;IAgBH;;OAEG;IACG,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAuB3D,OAAO,CAAC,iBAAiB;CAK1B;AAED,gCAAgC;AAChC,eAAO,MAAM,WAAW,aAGvB,CAAC"}
|
package/dist/deployer.js
DELETED
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JXR.js — Wranglerless Deployer
|
|
3
|
-
* Deploy projects to JXR Studios' Cloudflare infrastructure without wrangler.
|
|
4
|
-
* Users only need a JXR API key - no Cloudflare account required.
|
|
5
|
-
*/
|
|
6
|
-
import { readFile, stat } from "fs/promises";
|
|
7
|
-
import path from "path";
|
|
8
|
-
import { spawn } from "child_process";
|
|
9
|
-
/**
|
|
10
|
-
* JXRDeployer — Deploy to JXR Cloudflare infrastructure
|
|
11
|
-
* No wrangler config needed. Just your JXR API key.
|
|
12
|
-
*/
|
|
13
|
-
export class JXRDeployer {
|
|
14
|
-
apiKey;
|
|
15
|
-
projectId;
|
|
16
|
-
constructor(apiKey, projectId) {
|
|
17
|
-
this.apiKey = apiKey;
|
|
18
|
-
this.projectId = projectId || this.generateProjectId();
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Deploy the current project to JXR infrastructure
|
|
22
|
-
*/
|
|
23
|
-
async deploy(projectPath, config = {}) {
|
|
24
|
-
const env = config.environment || 'production';
|
|
25
|
-
const branch = config.branch || 'main';
|
|
26
|
-
const pid = config.projectId || this.projectId;
|
|
27
|
-
console.log(`🚀 Deploying to JXR ${env}...`);
|
|
28
|
-
const logs = [];
|
|
29
|
-
try {
|
|
30
|
-
// Verify project path exists
|
|
31
|
-
await stat(projectPath);
|
|
32
|
-
logs.push(`📁 Deploying from: ${projectPath}`);
|
|
33
|
-
// Create tarball of build files
|
|
34
|
-
const tarballPath = await this.createTarball(projectPath);
|
|
35
|
-
logs.push(`📦 Created tarball: ${tarballPath}`);
|
|
36
|
-
// Upload tarball
|
|
37
|
-
const uploadResult = await this.uploadTarball(tarballPath, pid, env, branch);
|
|
38
|
-
logs.push(`☁️ Uploaded to JXR`);
|
|
39
|
-
// Get deployment URL
|
|
40
|
-
const url = `https://${pid}.jxr.dev`;
|
|
41
|
-
logs.push(`🌐 Live at: ${url}`);
|
|
42
|
-
return {
|
|
43
|
-
success: true,
|
|
44
|
-
url,
|
|
45
|
-
deploymentId: uploadResult.deploymentId,
|
|
46
|
-
timestamp: new Date().toISOString(),
|
|
47
|
-
logs,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
const errorMsg = error instanceof Error ? error.message : 'Unknown error';
|
|
52
|
-
logs.push(`❌ Error: ${errorMsg}`);
|
|
53
|
-
return {
|
|
54
|
-
success: false,
|
|
55
|
-
url: '',
|
|
56
|
-
deploymentId: '',
|
|
57
|
-
timestamp: new Date().toISOString(),
|
|
58
|
-
logs,
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Create a tarball of the build directory
|
|
64
|
-
*/
|
|
65
|
-
async createTarball(projectPath) {
|
|
66
|
-
const tarballPath = path.join(process.cwd(), '.jxr-deploy.tar.gz');
|
|
67
|
-
return new Promise((resolve, reject) => {
|
|
68
|
-
const tar = spawn('tar', ['-czf', tarballPath, '-C', projectPath, '.']);
|
|
69
|
-
tar.on('close', (code) => {
|
|
70
|
-
if (code === 0) {
|
|
71
|
-
resolve(tarballPath);
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
reject(new Error(`tar exited with code ${code}`));
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
tar.on('error', reject);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Upload tarball to JXR API
|
|
82
|
-
*/
|
|
83
|
-
async uploadTarball(tarballPath, projectId, environment, branch) {
|
|
84
|
-
const formData = new FormData();
|
|
85
|
-
const fileContent = await readFile(tarballPath);
|
|
86
|
-
const blob = new Blob([fileContent]);
|
|
87
|
-
formData.append('build', blob, 'build.tar.gz');
|
|
88
|
-
formData.append('projectId', projectId);
|
|
89
|
-
formData.append('environment', environment);
|
|
90
|
-
formData.append('branch', branch);
|
|
91
|
-
const response = await fetch('https://api.jxrstudios.online/v1/deployments', {
|
|
92
|
-
method: 'POST',
|
|
93
|
-
headers: {
|
|
94
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
95
|
-
},
|
|
96
|
-
body: formData,
|
|
97
|
-
});
|
|
98
|
-
if (!response.ok) {
|
|
99
|
-
throw new Error(`Upload failed: ${response.statusText}`);
|
|
100
|
-
}
|
|
101
|
-
const result = await response.json();
|
|
102
|
-
return { deploymentId: result.deploymentId };
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Get deployment status
|
|
106
|
-
*/
|
|
107
|
-
async getStatus(deploymentId) {
|
|
108
|
-
const response = await fetch(`https://api.jxrstudios.online/v1/deployments/${deploymentId}`, {
|
|
109
|
-
headers: {
|
|
110
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
if (!response.ok) {
|
|
114
|
-
throw new Error(`Failed to get status: ${response.statusText}`);
|
|
115
|
-
}
|
|
116
|
-
return response.json();
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* List all deployments for a project
|
|
120
|
-
*/
|
|
121
|
-
async listDeployments(projectId) {
|
|
122
|
-
const pid = projectId || this.projectId;
|
|
123
|
-
const response = await fetch(`https://api.jxrstudios.online/v1/projects/${pid}/deployments`, {
|
|
124
|
-
headers: {
|
|
125
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
if (!response.ok) {
|
|
129
|
-
throw new Error(`Failed to list deployments: ${response.statusText}`);
|
|
130
|
-
}
|
|
131
|
-
return response.json();
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Rollback to a previous deployment
|
|
135
|
-
*/
|
|
136
|
-
async rollback(deploymentId) {
|
|
137
|
-
const response = await fetch(`https://api.jxrstudios.online/v1/deployments/${deploymentId}/rollback`, {
|
|
138
|
-
method: 'POST',
|
|
139
|
-
headers: {
|
|
140
|
-
'Authorization': `Bearer ${this.apiKey}`,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
if (!response.ok) {
|
|
144
|
-
throw new Error(`Rollback failed: ${response.statusText}`);
|
|
145
|
-
}
|
|
146
|
-
const result = await response.json();
|
|
147
|
-
return {
|
|
148
|
-
success: true,
|
|
149
|
-
url: result.url,
|
|
150
|
-
deploymentId: result.deploymentId,
|
|
151
|
-
timestamp: new Date().toISOString(),
|
|
152
|
-
logs: ['Rollback successful'],
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
generateProjectId() {
|
|
156
|
-
const timestamp = Date.now().toString(36);
|
|
157
|
-
const random = Math.random().toString(36).substring(2, 8);
|
|
158
|
-
return `jxr-${timestamp}-${random}`;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/** Global deployer singleton */
|
|
162
|
-
export const jxrDeployer = new JXRDeployer(process.env.JXR_API_KEY || '', process.env.JXR_PROJECT_ID);
|
|
163
|
-
//# sourceMappingURL=deployer.js.map
|
package/dist/deployer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deployer.js","sourceRoot":"","sources":["../src/deployer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAW,IAAI,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAuBtC;;;GAGG;AACH,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,SAAS,CAAS;IAE1B,YAAY,MAAc,EAAE,SAAkB;QAC5C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,SAAuB,EAAE;QACzD,MAAM,GAAG,GAAG,MAAM,CAAC,WAAW,IAAI,YAAY,CAAC;QAC/C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC;QACvC,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,SAAS,CAAC;QAE/C,OAAO,CAAC,GAAG,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;QAE7C,MAAM,IAAI,GAAa,EAAE,CAAC;QAE1B,IAAI,CAAC;YACH,6BAA6B;YAC7B,MAAM,IAAI,CAAC,WAAW,CAAC,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,sBAAsB,WAAW,EAAE,CAAC,CAAC;YAE/C,gCAAgC;YAChC,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,IAAI,CAAC,uBAAuB,WAAW,EAAE,CAAC,CAAC;YAEhD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CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,oBAAoB,QAAQ,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAErC,OAAO;YACL,OAAO,EAAE,IAAI;YACb,GAAG,EAAE,MAAM,CAAC,GAAG;YACf,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACnC,IAAI,EAAE,CAAC,qBAAqB,CAAC;SAC9B,CAAC;IACJ,CAAC;IAEO,iBAAiB;QACvB,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC1D,OAAO,OAAO,SAAS,IAAI,MAAM,EAAE,CAAC;IACtC,CAAC;CACF;AAED,gCAAgC;AAChC,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,WAAW,CACxC,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,EAAE,EAC7B,OAAO,CAAC,GAAG,CAAC,cAAc,CAC3B,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
export interface TranspilerOptions {
|
|
2
|
-
filename: string;
|
|
3
|
-
presets?: string[];
|
|
4
|
-
plugins?: any[];
|
|
5
|
-
cache?: boolean;
|
|
6
|
-
}
|
|
7
|
-
export interface TranspilationResult {
|
|
8
|
-
code: string;
|
|
9
|
-
map?: any;
|
|
10
|
-
error?: Error;
|
|
11
|
-
cached?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export declare class EnhancedTranspiler {
|
|
14
|
-
private transformCache;
|
|
15
|
-
private dependencyGraph;
|
|
16
|
-
private options;
|
|
17
|
-
constructor(options?: Partial<TranspilerOptions>);
|
|
18
|
-
transpileTypeScript(code: string, filename: string, options?: Partial<TranspilerOptions>): TranspilationResult;
|
|
19
|
-
transpileJSX(code: string, filename: string, options?: Partial<TranspilerOptions>): TranspilationResult;
|
|
20
|
-
private createImportTransformer;
|
|
21
|
-
private resolveImportPath;
|
|
22
|
-
trackDependencies(filename: string, dependencies: string[]): void;
|
|
23
|
-
invalidateCache(changedFiles: string[]): void;
|
|
24
|
-
clearCache(): void;
|
|
25
|
-
invalidateFile(filename: string): void;
|
|
26
|
-
getCacheStats(): {
|
|
27
|
-
size: number;
|
|
28
|
-
hitRate: number;
|
|
29
|
-
};
|
|
30
|
-
extractDependencies(code: string): string[];
|
|
31
|
-
validateTranspiledCode(code: string): {
|
|
32
|
-
valid: boolean;
|
|
33
|
-
errors: string[];
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=enhanced-transpiler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"enhanced-transpiler.d.ts","sourceRoot":"","sources":["../src/enhanced-transpiler.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAA;IAClB,OAAO,CAAC,EAAE,GAAG,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,KAAK,CAAC,EAAE,KAAK,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,cAAc,CAAyC;IAC/D,OAAO,CAAC,eAAe,CAAiC;IACxD,OAAO,CAAC,OAAO,CAA4B;gBAE/B,OAAO,GAAE,OAAO,CAAC,iBAAiB,CAAM;IAIpD,mBAA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