@roxyon/deploy-core 0.1.0

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/index.js ADDED
@@ -0,0 +1,468 @@
1
+ // src/archive.ts
2
+ import { readFile, readdir, stat } from "fs/promises";
3
+ import { join, relative, sep } from "path";
4
+ import ignore from "ignore";
5
+ import { create as tarCreate } from "tar";
6
+ var ALWAYS_IGNORE = [
7
+ "node_modules",
8
+ ".git",
9
+ ".next",
10
+ ".nuxt",
11
+ ".venv",
12
+ "__pycache__",
13
+ ".DS_Store",
14
+ ".roxyon",
15
+ "dist/.cache"
16
+ ];
17
+ async function readIgnoreFile(root, name) {
18
+ try {
19
+ return (await readFile(join(root, name), "utf8")).split(/\r?\n/);
20
+ } catch {
21
+ return [];
22
+ }
23
+ }
24
+ async function buildIgnore(root) {
25
+ const ig = ignore().add(ALWAYS_IGNORE);
26
+ const roxyon = await readIgnoreFile(root, ".roxyonignore");
27
+ if (roxyon.length) ig.add(roxyon);
28
+ else ig.add(await readIgnoreFile(root, ".gitignore"));
29
+ return ig;
30
+ }
31
+ async function listFiles(root, ig) {
32
+ const files = [];
33
+ async function walk(dir) {
34
+ const entries = await readdir(dir, { withFileTypes: true });
35
+ for (const entry of entries) {
36
+ const abs = join(dir, entry.name);
37
+ const rel = relative(root, abs).split(sep).join("/");
38
+ if (!rel || ig.ignores(rel) || ig.ignores(`${rel}/`)) continue;
39
+ if (entry.isDirectory()) {
40
+ await walk(abs);
41
+ } else if (entry.isFile() || entry.isSymbolicLink()) {
42
+ files.push(rel);
43
+ }
44
+ }
45
+ }
46
+ await walk(root);
47
+ return files.sort();
48
+ }
49
+ async function packDirectory(root, opts = {}) {
50
+ const ig = await buildIgnore(root);
51
+ const files = await listFiles(root, ig);
52
+ if (files.length === 0) {
53
+ throw new Error(
54
+ `Nothing to deploy from ${root} \u2014 every file is ignored or the folder is empty.`
55
+ );
56
+ }
57
+ const stream = tarCreate(
58
+ {
59
+ gzip: true,
60
+ cwd: root,
61
+ portable: true,
62
+ mtime: /* @__PURE__ */ new Date(0),
63
+ // stable -> byte-identical archive for an unchanged tree
64
+ prefix: opts.prefix,
65
+ follow: false
66
+ },
67
+ files
68
+ );
69
+ const chunks = [];
70
+ let bytes = 0;
71
+ const max = opts.maxBytes ?? 512 * 1024 * 1024;
72
+ for await (const chunk of stream) {
73
+ bytes += chunk.length;
74
+ if (bytes > max) {
75
+ throw new Error(
76
+ `Deploy archive exceeds ${max / 1024 / 1024 | 0} MB. Add large files to .roxyonignore.`
77
+ );
78
+ }
79
+ chunks.push(chunk);
80
+ }
81
+ return { buffer: Buffer.concat(chunks), files, bytes };
82
+ }
83
+ async function measure(root, files) {
84
+ let total = 0;
85
+ for (const f of files) {
86
+ try {
87
+ total += (await stat(join(root, f))).size;
88
+ } catch {
89
+ }
90
+ }
91
+ return total;
92
+ }
93
+
94
+ // src/detect.ts
95
+ import { readFile as readFile2, readdir as readdir2 } from "fs/promises";
96
+ import { join as join2 } from "path";
97
+ async function exists(root, name) {
98
+ try {
99
+ await readFile2(join2(root, name));
100
+ return true;
101
+ } catch {
102
+ return false;
103
+ }
104
+ }
105
+ async function readJson(root, name) {
106
+ try {
107
+ return JSON.parse(await readFile2(join2(root, name), "utf8"));
108
+ } catch {
109
+ return void 0;
110
+ }
111
+ }
112
+ async function detectRuntime(root) {
113
+ const pkg = await readJson(root, "package.json");
114
+ const hasConfigJson = await exists(root, "config.json");
115
+ let hasViews = false;
116
+ try {
117
+ hasViews = (await readdir2(join2(root, "src", "views"))).length >= 0;
118
+ } catch {
119
+ hasViews = false;
120
+ }
121
+ if (hasConfigJson && hasViews) {
122
+ const deps = {
123
+ ...pkg?.dependencies,
124
+ ...pkg?.devDependencies
125
+ };
126
+ if (!("next" in deps) && !("nuxt" in deps) && !("express" in deps) && !("fastify" in deps)) {
127
+ return { runtime: "lumen", reason: "config.json + src/views/ and no server framework" };
128
+ }
129
+ }
130
+ if (pkg) {
131
+ const scripts = pkg.scripts ?? {};
132
+ const start = scripts.start ? "npm run start" : scripts.serve ? "npm run serve" : "node .";
133
+ const deps = { ...pkg.dependencies, ...pkg.devDependencies };
134
+ if ("next" in deps)
135
+ return { runtime: "node", reason: "Next.js in package.json", start: "npm run start" };
136
+ if ("nuxt" in deps)
137
+ return { runtime: "node", reason: "Nuxt in package.json", start: "npm run start" };
138
+ return { runtime: "node", reason: "package.json present", start };
139
+ }
140
+ if (await exists(root, "requirements.txt") || await exists(root, "pyproject.toml")) {
141
+ return {
142
+ runtime: "python",
143
+ reason: "requirements.txt / pyproject.toml",
144
+ start: "gunicorn app:app"
145
+ };
146
+ }
147
+ if (await exists(root, "composer.json") || await exists(root, "server.php")) {
148
+ return { runtime: "php", reason: "composer.json / server.php", start: "php8.4 server.php" };
149
+ }
150
+ return { runtime: "lumen", reason: "no framework markers \u2014 treating as a static site" };
151
+ }
152
+
153
+ // src/project.ts
154
+ import { mkdir, readFile as readFile3, writeFile } from "fs/promises";
155
+ import { basename, dirname, resolve } from "path";
156
+ import { LUMEN_BUILD, RUNTIMES } from "@roxyon/api-client";
157
+ var PROJECT_FILE = "roxyon.json";
158
+ function projectConfigPath(cwd = process.cwd()) {
159
+ return resolve(cwd, PROJECT_FILE);
160
+ }
161
+ async function loadProjectConfig(cwd = process.cwd()) {
162
+ try {
163
+ return JSON.parse(await readFile3(projectConfigPath(cwd), "utf8"));
164
+ } catch {
165
+ return void 0;
166
+ }
167
+ }
168
+ async function saveProjectConfig(config, cwd = process.cwd()) {
169
+ const path = projectConfigPath(cwd);
170
+ await mkdir(dirname(path), { recursive: true });
171
+ await writeFile(path, `${JSON.stringify(config, null, 2)}
172
+ `);
173
+ return path;
174
+ }
175
+ function buildProjectConfig(input) {
176
+ const folder = String(input.folder ?? "").replace(/^\/+|\/+$/g, "");
177
+ const config = {
178
+ name: input.name ?? basename(input.cwd),
179
+ host: input.host,
180
+ folder,
181
+ runtime: input.runtime,
182
+ kind: input.runtime === "lumen" ? "static" : "app"
183
+ };
184
+ if (input.runtime === "lumen") {
185
+ config.build = LUMEN_BUILD.command;
186
+ config.outDir = LUMEN_BUILD.outDir;
187
+ } else {
188
+ const spec = RUNTIMES[input.runtime];
189
+ config.runtimeVersion = spec.defaultVersion;
190
+ config.preset = spec.presets[0]?.[0];
191
+ config.start = input.start ?? spec.command;
192
+ config.public = true;
193
+ config.build = "";
194
+ }
195
+ return config;
196
+ }
197
+
198
+ // src/deploy.ts
199
+ import { access } from "fs/promises";
200
+ import { resolve as resolve2 } from "path";
201
+ import {
202
+ RUNTIMES as RUNTIMES2,
203
+ RoxyonApiError,
204
+ isAuthError
205
+ } from "@roxyon/api-client";
206
+
207
+ // src/run-command.ts
208
+ import { spawn } from "child_process";
209
+ function runShellCommand(command, cwd, reporter) {
210
+ return new Promise((resolvePromise) => {
211
+ const child = spawn(command, { cwd, shell: true, stdio: ["ignore", "pipe", "pipe"] });
212
+ const pipe = (buf) => {
213
+ for (const line of buf.toString("utf8").split("\n")) {
214
+ if (line.trim()) reporter?.log?.(line);
215
+ }
216
+ };
217
+ child.stdout?.on("data", pipe);
218
+ child.stderr?.on("data", pipe);
219
+ child.on("close", (code) => resolvePromise(code ?? 0));
220
+ child.on("error", () => resolvePromise(127));
221
+ });
222
+ }
223
+
224
+ // src/deploy.ts
225
+ var DeployError = class extends Error {
226
+ code;
227
+ constructor(message, code) {
228
+ super(message);
229
+ this.name = "DeployError";
230
+ this.code = code;
231
+ }
232
+ };
233
+ var sleep = (ms) => new Promise((r) => setTimeout(r, ms));
234
+ async function deployProject(params) {
235
+ const { cwd, roxyon, reporter } = params;
236
+ const runCommand = params.runCommand ?? runShellCommand;
237
+ const config = await loadProjectConfig(cwd);
238
+ if (!config) {
239
+ throw new DeployError("No roxyon.json in this directory \u2014 run init first.", "no-config");
240
+ }
241
+ const ctx = await roxyon.account.context().catch((e) => {
242
+ if (isAuthError(e)) throw new DeployError("Session expired \u2014 sign in again.", "auth");
243
+ throw e;
244
+ });
245
+ const domain = ctx.domains.find((d) => d.name === config.host);
246
+ if (!domain) {
247
+ throw new DeployError(
248
+ `Host "${config.host}" is not on this account (have: ${ctx.domains.map((d) => d.name).join(", ") || "none"}).`,
249
+ "bad-host"
250
+ );
251
+ }
252
+ if (config.build && params.build !== false) {
253
+ reporter?.step?.(`Build: ${config.build}`);
254
+ const code = await runCommand(config.build, cwd, reporter);
255
+ if (code !== 0) throw new DeployError(`Build command exited ${code}.`, "build-failed");
256
+ }
257
+ const artifactDir = config.kind === "static" && config.outDir ? resolve2(cwd, config.outDir) : cwd;
258
+ if (config.kind === "static" && config.outDir) {
259
+ await access(artifactDir).catch(() => {
260
+ throw new DeployError(
261
+ `Build output "${config.outDir}" not found \u2014 did the build run?`,
262
+ "no-build-output"
263
+ );
264
+ });
265
+ }
266
+ reporter?.step?.(`Packing ${artifactDir === cwd ? "." : config.outDir}`);
267
+ const pack = await packDirectory(artifactDir);
268
+ reporter?.log?.(`${pack.files.length} files \xB7 ${(pack.bytes / 1024).toFixed(0)} KB`);
269
+ if (config.kind === "static") {
270
+ reporter?.step?.(`Uploading to ${config.host}${config.folder ? `/${config.folder}` : ""}`);
271
+ let res;
272
+ try {
273
+ res = await roxyon.sites.deploy(config.host, config.folder, pack.buffer);
274
+ } catch (err) {
275
+ throw new DeployError(
276
+ err instanceof RoxyonApiError ? err.message : String(err),
277
+ "upload-failed"
278
+ );
279
+ }
280
+ const url2 = `https://${res.host}${res.path && res.path !== "/" ? res.path : ""}`;
281
+ reporter?.step?.(`Live \u2014 ${url2}`);
282
+ return { kind: "static", ok: true, url: url2, files: res.files ?? pack.files.length, config };
283
+ }
284
+ const runtime = config.runtime === "lumen" ? "node" : config.runtime;
285
+ const spec = RUNTIMES2[runtime];
286
+ const target = config.application ?? {
287
+ host: config.host,
288
+ folder: config.folder,
289
+ runtime,
290
+ runtimeVersion: config.runtimeVersion ?? spec.defaultVersion,
291
+ preset: config.preset ?? spec.presets[0]?.[0] ?? runtime,
292
+ command: config.start ?? spec.command,
293
+ public: config.public ?? true
294
+ };
295
+ reporter?.step?.(
296
+ config.application ? "Uploading source" : "Creating the application & uploading"
297
+ );
298
+ let revision = 0;
299
+ let appId;
300
+ try {
301
+ const res = await roxyon.applications.uploadSource(target, pack.buffer);
302
+ revision = res.configRevision ?? 0;
303
+ appId = res.application;
304
+ if (res.created && appId && appId !== config.application) {
305
+ config.application = appId;
306
+ await saveProjectConfig(config, cwd);
307
+ reporter?.log?.(`application ${appId} created`);
308
+ }
309
+ } catch (err) {
310
+ throw new DeployError(
311
+ err instanceof RoxyonApiError ? err.message : String(err),
312
+ config.application ? "upload-failed" : "create-failed"
313
+ );
314
+ }
315
+ const url = config.public ? `https://${config.host}${config.folder ? `/${config.folder}` : ""}` : void 0;
316
+ if (params.follow === false) {
317
+ reporter?.step?.(`Build queued (revision ${revision})`);
318
+ return {
319
+ kind: "app",
320
+ ok: true,
321
+ application: appId,
322
+ status: "building",
323
+ revision,
324
+ url,
325
+ config,
326
+ logs: []
327
+ };
328
+ }
329
+ return watch(roxyon, appId, {
330
+ reporter,
331
+ url,
332
+ config,
333
+ pollMs: params.pollMs ?? 3e3,
334
+ timeoutMs: params.timeoutMs ?? 10 * 60 * 1e3
335
+ });
336
+ }
337
+ async function watch(roxyon, appId, opts) {
338
+ const started = Date.now();
339
+ const seen = /* @__PURE__ */ new Set();
340
+ const collected = [];
341
+ let lastStatus = "";
342
+ opts.reporter?.step?.("Building");
343
+ while (true) {
344
+ await sleep(opts.pollMs);
345
+ let app;
346
+ try {
347
+ app = await roxyon.account.getApp(appId);
348
+ } catch {
349
+ }
350
+ if (!app) {
351
+ if (Date.now() - started > opts.timeoutMs) break;
352
+ continue;
353
+ }
354
+ const cfg = app.configRevision;
355
+ const applied = app.appliedRevision;
356
+ const status = app.status;
357
+ if (status !== lastStatus) {
358
+ opts.reporter?.step?.(`${status || "pending"} (${applied}/${cfg})`);
359
+ lastStatus = status;
360
+ }
361
+ try {
362
+ for (const line of await roxyon.applications.logs(appId, 40)) {
363
+ if (line && !seen.has(line)) {
364
+ seen.add(line);
365
+ collected.push(line);
366
+ opts.reporter?.log?.(line);
367
+ }
368
+ }
369
+ } catch {
370
+ }
371
+ if (cfg <= applied && status === "running") {
372
+ opts.reporter?.step?.(`Live${opts.url ? ` \u2014 ${opts.url}` : ""}`);
373
+ return {
374
+ kind: "app",
375
+ ok: true,
376
+ application: appId,
377
+ status: "running",
378
+ revision: applied,
379
+ url: opts.url,
380
+ config: opts.config,
381
+ logs: collected
382
+ };
383
+ }
384
+ if (status === "failed") {
385
+ return {
386
+ kind: "app",
387
+ ok: false,
388
+ application: appId,
389
+ status: "failed",
390
+ error: (app.lastError || "Deploy failed.").trim(),
391
+ config: opts.config,
392
+ logs: collected
393
+ };
394
+ }
395
+ if (Date.now() - started > opts.timeoutMs) break;
396
+ }
397
+ return {
398
+ kind: "app",
399
+ ok: false,
400
+ application: appId,
401
+ status: "timeout",
402
+ error: "Still building after the timeout \u2014 check `roxyon logs`.",
403
+ config: opts.config,
404
+ logs: collected
405
+ };
406
+ }
407
+
408
+ // src/credentials.ts
409
+ import { chmod, mkdir as mkdir2, readFile as readFile4, rm, writeFile as writeFile2 } from "fs/promises";
410
+ import { homedir } from "os";
411
+ import { join as join3 } from "path";
412
+ function credentialsDir() {
413
+ return join3(homedir(), ".roxyon");
414
+ }
415
+ function credentialsPath() {
416
+ return join3(credentialsDir(), "config.json");
417
+ }
418
+ function endpointsFromEnv() {
419
+ return {
420
+ apiUrl: process.env.ROXYON_API_URL,
421
+ consoleUrl: process.env.ROXYON_CONSOLE_URL
422
+ };
423
+ }
424
+ function tokenFromEnv() {
425
+ return process.env.ROXYON_TOKEN || void 0;
426
+ }
427
+ async function loadCredentials() {
428
+ try {
429
+ return JSON.parse(await readFile4(credentialsPath(), "utf8"));
430
+ } catch {
431
+ return void 0;
432
+ }
433
+ }
434
+ async function saveCredentials(creds) {
435
+ const path = credentialsPath();
436
+ await mkdir2(credentialsDir(), { recursive: true, mode: 448 });
437
+ await writeFile2(path, `${JSON.stringify(creds, null, 2)}
438
+ `, { mode: 384 });
439
+ await chmod(path, 384).catch(() => void 0);
440
+ return path;
441
+ }
442
+ async function clearCredentials() {
443
+ await rm(credentialsPath(), { force: true });
444
+ }
445
+ export {
446
+ ALWAYS_IGNORE,
447
+ DeployError,
448
+ PROJECT_FILE,
449
+ buildIgnore,
450
+ buildProjectConfig,
451
+ clearCredentials,
452
+ credentialsDir,
453
+ credentialsPath,
454
+ deployProject,
455
+ detectRuntime,
456
+ endpointsFromEnv,
457
+ listFiles,
458
+ loadCredentials,
459
+ loadProjectConfig,
460
+ measure,
461
+ packDirectory,
462
+ projectConfigPath,
463
+ runShellCommand,
464
+ saveCredentials,
465
+ saveProjectConfig,
466
+ tokenFromEnv
467
+ };
468
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/archive.ts","../src/detect.ts","../src/project.ts","../src/deploy.ts","../src/run-command.ts","../src/credentials.ts"],"sourcesContent":["import { readFile, readdir, stat } from 'node:fs/promises';\nimport { join, relative, sep } from 'node:path';\nimport ignore, { type Ignore } from 'ignore';\nimport { create as tarCreate } from 'tar';\n\n/** Always excluded, regardless of ignore files — build artefacts and VCS/OS cruft. */\nexport const ALWAYS_IGNORE = [\n 'node_modules',\n '.git',\n '.next',\n '.nuxt',\n '.venv',\n '__pycache__',\n '.DS_Store',\n '.roxyon',\n 'dist/.cache',\n];\n\nasync function readIgnoreFile(root: string, name: string): Promise<string[]> {\n try {\n return (await readFile(join(root, name), 'utf8')).split(/\\r?\\n/);\n } catch {\n return [];\n }\n}\n\n/** Build the ignore matcher: `.roxyonignore` if present, else `.gitignore`, plus the always-list. */\nexport async function buildIgnore(root: string): Promise<Ignore> {\n const ig = ignore().add(ALWAYS_IGNORE);\n const roxyon = await readIgnoreFile(root, '.roxyonignore');\n if (roxyon.length) ig.add(roxyon);\n else ig.add(await readIgnoreFile(root, '.gitignore'));\n return ig;\n}\n\n/** Recursively list files under `root` that survive the ignore matcher (POSIX-relative paths). */\nexport async function listFiles(root: string, ig: Ignore): Promise<string[]> {\n const files: string[] = [];\n\n async function walk(dir: string): Promise<void> {\n const entries = await readdir(dir, { withFileTypes: true });\n for (const entry of entries) {\n const abs = join(dir, entry.name);\n const rel = relative(root, abs).split(sep).join('/');\n if (!rel || ig.ignores(rel) || ig.ignores(`${rel}/`)) continue;\n if (entry.isDirectory()) {\n await walk(abs);\n } else if (entry.isFile() || entry.isSymbolicLink()) {\n files.push(rel);\n }\n }\n }\n\n await walk(root);\n return files.sort();\n}\n\nexport interface PackResult {\n buffer: Buffer;\n files: string[];\n bytes: number;\n}\n\n/**\n * Create a deterministic gzipped tarball of `root` (minus ignored paths).\n * `prefix`, when given, is prepended to every entry path inside the archive.\n */\nexport async function packDirectory(\n root: string,\n opts: { prefix?: string; maxBytes?: number } = {},\n): Promise<PackResult> {\n const ig = await buildIgnore(root);\n const files = await listFiles(root, ig);\n if (files.length === 0) {\n throw new Error(\n `Nothing to deploy from ${root} — every file is ignored or the folder is empty.`,\n );\n }\n\n const stream = tarCreate(\n {\n gzip: true,\n cwd: root,\n portable: true,\n mtime: new Date(0), // stable -> byte-identical archive for an unchanged tree\n prefix: opts.prefix,\n follow: false,\n },\n files,\n );\n\n const chunks: Buffer[] = [];\n let bytes = 0;\n const max = opts.maxBytes ?? 512 * 1024 * 1024;\n for await (const chunk of stream as AsyncIterable<Buffer>) {\n bytes += chunk.length;\n if (bytes > max) {\n throw new Error(\n `Deploy archive exceeds ${(max / 1024 / 1024) | 0} MB. Add large files to .roxyonignore.`,\n );\n }\n chunks.push(chunk);\n }\n\n return { buffer: Buffer.concat(chunks), files, bytes };\n}\n\n/** Total on-disk size of a set of files. */\nexport async function measure(root: string, files: string[]): Promise<number> {\n let total = 0;\n for (const f of files) {\n try {\n total += (await stat(join(root, f))).size;\n } catch {\n /* ignore */\n }\n }\n return total;\n}\n","import { readFile, readdir } from 'node:fs/promises';\nimport { join } from 'node:path';\nimport type { RuntimeName } from '@roxyon/api-client';\n\nexport interface Detection {\n runtime: RuntimeName;\n /** why we think so — shown to the user, who can override */\n reason: string;\n /** best-guess start command for a server runtime */\n start?: string;\n}\n\nasync function exists(root: string, name: string): Promise<boolean> {\n try {\n await readFile(join(root, name));\n return true;\n } catch {\n return false;\n }\n}\n\nasync function readJson(root: string, name: string): Promise<Record<string, unknown> | undefined> {\n try {\n return JSON.parse(await readFile(join(root, name), 'utf8')) as Record<string, unknown>;\n } catch {\n return undefined;\n }\n}\n\n/** Best-effort project-type detection. Deterministic; the caller confirms. */\nexport async function detectRuntime(root: string): Promise<Detection> {\n const pkg = await readJson(root, 'package.json');\n const hasConfigJson = await exists(root, 'config.json');\n let hasViews = false;\n try {\n hasViews = (await readdir(join(root, 'src', 'views'))).length >= 0;\n } catch {\n hasViews = false;\n }\n\n if (hasConfigJson && hasViews) {\n const deps = {\n ...(pkg?.dependencies as object),\n ...(pkg?.devDependencies as object),\n } as Record<string, string>;\n if (!('next' in deps) && !('nuxt' in deps) && !('express' in deps) && !('fastify' in deps)) {\n return { runtime: 'lumen', reason: 'config.json + src/views/ and no server framework' };\n }\n }\n\n if (pkg) {\n const scripts = (pkg.scripts as Record<string, string>) ?? {};\n const start = scripts.start ? 'npm run start' : scripts.serve ? 'npm run serve' : 'node .';\n const deps = { ...(pkg.dependencies as object), ...(pkg.devDependencies as object) } as Record<\n string,\n string\n >;\n if ('next' in deps)\n return { runtime: 'node', reason: 'Next.js in package.json', start: 'npm run start' };\n if ('nuxt' in deps)\n return { runtime: 'node', reason: 'Nuxt in package.json', start: 'npm run start' };\n return { runtime: 'node', reason: 'package.json present', start };\n }\n\n if ((await exists(root, 'requirements.txt')) || (await exists(root, 'pyproject.toml'))) {\n return {\n runtime: 'python',\n reason: 'requirements.txt / pyproject.toml',\n start: 'gunicorn app:app',\n };\n }\n\n if ((await exists(root, 'composer.json')) || (await exists(root, 'server.php'))) {\n return { runtime: 'php', reason: 'composer.json / server.php', start: 'php8.4 server.php' };\n }\n\n return { runtime: 'lumen', reason: 'no framework markers — treating as a static site' };\n}\n","import { mkdir, readFile, writeFile } from 'node:fs/promises';\nimport { basename, dirname, resolve } from 'node:path';\nimport { type DeployKind, LUMEN_BUILD, RUNTIMES, type RuntimeName } from '@roxyon/api-client';\n\nexport type { DeployKind };\n\nexport interface ProjectConfig {\n name: string;\n /** `Applications.objectId`, filled after the first `app`-kind deploy. */\n application?: string;\n /** Route host — `Domains.Name`. */\n host: string;\n /** Sub-path under the host's docroot / source tree. `\"\"` = root. */\n folder: string;\n runtime: RuntimeName;\n runtimeVersion?: string;\n preset?: string;\n kind: DeployKind;\n /** Local build command (LumenJS / static). Empty for server runtimes. */\n build?: string;\n /** Directory the build writes to (relative to project root). */\n outDir?: string;\n /** Web-process start command (app kind only). */\n start?: string;\n /** Serve the app on the host instead of the host's own files. */\n public?: boolean;\n}\n\nexport const PROJECT_FILE = 'roxyon.json';\n\nexport function projectConfigPath(cwd: string = process.cwd()): string {\n return resolve(cwd, PROJECT_FILE);\n}\n\nexport async function loadProjectConfig(\n cwd: string = process.cwd(),\n): Promise<ProjectConfig | undefined> {\n try {\n return JSON.parse(await readFile(projectConfigPath(cwd), 'utf8')) as ProjectConfig;\n } catch {\n return undefined;\n }\n}\n\nexport async function saveProjectConfig(\n config: ProjectConfig,\n cwd: string = process.cwd(),\n): Promise<string> {\n const path = projectConfigPath(cwd);\n await mkdir(dirname(path), { recursive: true });\n await writeFile(path, `${JSON.stringify(config, null, 2)}\\n`);\n return path;\n}\n\nexport interface BuildConfigInput {\n cwd: string;\n runtime: RuntimeName;\n host: string;\n folder?: string;\n name?: string;\n start?: string;\n}\n\n/**\n * Produce a `ProjectConfig` from a resolved runtime + host. Shared by the CLI's\n * `roxyon init` and the MCP `roxyon_init` tool so both write the same shape.\n */\nexport function buildProjectConfig(input: BuildConfigInput): ProjectConfig {\n const folder = String(input.folder ?? '').replace(/^\\/+|\\/+$/g, '');\n const config: ProjectConfig = {\n name: input.name ?? basename(input.cwd),\n host: input.host,\n folder,\n runtime: input.runtime,\n kind: input.runtime === 'lumen' ? 'static' : 'app',\n };\n\n if (input.runtime === 'lumen') {\n config.build = LUMEN_BUILD.command;\n config.outDir = LUMEN_BUILD.outDir;\n } else {\n const spec = RUNTIMES[input.runtime];\n config.runtimeVersion = spec.defaultVersion;\n config.preset = spec.presets[0]?.[0];\n config.start = input.start ?? spec.command;\n config.public = true;\n config.build = '';\n }\n return config;\n}\n","import { access } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport {\n type AccountApp,\n RUNTIMES,\n type Roxyon,\n RoxyonApiError,\n isAuthError,\n} from '@roxyon/api-client';\nimport { packDirectory } from './archive.js';\nimport { type ProjectConfig, loadProjectConfig, saveProjectConfig } from './project.js';\nimport { runShellCommand } from './run-command.js';\n\nexport interface DeployReporter {\n /** A high-level phase change (\"Building\", \"Uploading\", \"Live\"). */\n step?: (msg: string) => void;\n /** A single build- or runtime-log line. */\n log?: (line: string) => void;\n}\n\nexport interface DeployParams {\n cwd: string;\n /** An authenticated client. */\n roxyon: Roxyon;\n /** Subscription objectId / Name to prefer when the account has several. */\n preferredSubscription?: string;\n /** Run the configured build command (default true). */\n build?: boolean;\n /** For app deploys: poll until running/failed (default true). */\n follow?: boolean;\n pollMs?: number;\n timeoutMs?: number;\n reporter?: DeployReporter;\n /** Override the build-command runner (default: spawn a shell). */\n runCommand?: (command: string, cwd: string, reporter?: DeployReporter) => Promise<number>;\n}\n\nexport type DeployOutcome =\n | { kind: 'static'; ok: true; url: string; files: number; config: ProjectConfig }\n | {\n kind: 'app';\n ok: true;\n application: string;\n status: string;\n revision: number;\n url?: string;\n config: ProjectConfig;\n logs: string[];\n }\n | {\n kind: 'app';\n ok: false;\n application: string;\n status: string;\n error: string;\n config: ProjectConfig;\n logs: string[];\n };\n\nexport class DeployError extends Error {\n readonly code:\n | 'no-config'\n | 'auth'\n | 'bad-host'\n | 'build-failed'\n | 'no-build-output'\n | 'upload-failed'\n | 'create-failed';\n constructor(message: string, code: DeployError['code']) {\n super(message);\n this.name = 'DeployError';\n this.code = code;\n }\n}\n\nconst sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));\n\n/**\n * Build (if configured), archive, upload, and — for app runtimes — poll until\n * the deploy settles. Self-contained: one `/account/context` call validates the\n * host (works with a session token or a `roxp_` PAT), and the console creates\n * the application on the first deploy — the new id is written back to\n * `roxyon.json`.\n */\nexport async function deployProject(params: DeployParams): Promise<DeployOutcome> {\n const { cwd, roxyon, reporter } = params;\n const runCommand = params.runCommand ?? runShellCommand;\n\n const config = await loadProjectConfig(cwd);\n if (!config) {\n throw new DeployError('No roxyon.json in this directory — run init first.', 'no-config');\n }\n\n // One call — works with a session token or a PAT.\n const ctx = await roxyon.account.context().catch((e) => {\n if (isAuthError(e)) throw new DeployError('Session expired — sign in again.', 'auth');\n throw e;\n });\n const domain = ctx.domains.find((d) => d.name === config.host);\n if (!domain) {\n throw new DeployError(\n `Host \"${config.host}\" is not on this account (have: ${\n ctx.domains.map((d) => d.name).join(', ') || 'none'\n }).`,\n 'bad-host',\n );\n }\n\n // ---- build ----\n if (config.build && params.build !== false) {\n reporter?.step?.(`Build: ${config.build}`);\n const code = await runCommand(config.build, cwd, reporter);\n if (code !== 0) throw new DeployError(`Build command exited ${code}.`, 'build-failed');\n }\n\n // ---- pack ----\n const artifactDir = config.kind === 'static' && config.outDir ? resolve(cwd, config.outDir) : cwd;\n if (config.kind === 'static' && config.outDir) {\n await access(artifactDir).catch(() => {\n throw new DeployError(\n `Build output \"${config.outDir}\" not found — did the build run?`,\n 'no-build-output',\n );\n });\n }\n reporter?.step?.(`Packing ${artifactDir === cwd ? '.' : config.outDir}`);\n const pack = await packDirectory(artifactDir);\n reporter?.log?.(`${pack.files.length} files · ${(pack.bytes / 1024).toFixed(0)} KB`);\n\n // ---- static ----\n if (config.kind === 'static') {\n reporter?.step?.(`Uploading to ${config.host}${config.folder ? `/${config.folder}` : ''}`);\n let res: Awaited<ReturnType<typeof roxyon.sites.deploy>>;\n try {\n res = await roxyon.sites.deploy(config.host, config.folder, pack.buffer);\n } catch (err) {\n throw new DeployError(\n err instanceof RoxyonApiError ? err.message : String(err),\n 'upload-failed',\n );\n }\n const url = `https://${res.host}${res.path && res.path !== '/' ? res.path : ''}`;\n reporter?.step?.(`Live — ${url}`);\n return { kind: 'static', ok: true, url, files: res.files ?? pack.files.length, config };\n }\n\n // ---- app ----\n // The console's /applications/deploy creates the app rows on the first deploy\n // (no `application` id yet) from the host + runtime params — one trusted call,\n // so a PAT-only CI job needs no BaaS write access.\n const runtime = config.runtime === 'lumen' ? 'node' : config.runtime;\n const spec = RUNTIMES[runtime];\n const target = config.application ?? {\n host: config.host,\n folder: config.folder,\n runtime,\n runtimeVersion: config.runtimeVersion ?? spec.defaultVersion,\n preset: config.preset ?? spec.presets[0]?.[0] ?? runtime,\n command: config.start ?? spec.command,\n public: config.public ?? true,\n };\n\n reporter?.step?.(\n config.application ? 'Uploading source' : 'Creating the application & uploading',\n );\n let revision = 0;\n let appId: string;\n try {\n const res = await roxyon.applications.uploadSource(target, pack.buffer);\n revision = res.configRevision ?? 0;\n appId = res.application;\n if (res.created && appId && appId !== config.application) {\n config.application = appId;\n await saveProjectConfig(config, cwd);\n reporter?.log?.(`application ${appId} created`);\n }\n } catch (err) {\n throw new DeployError(\n err instanceof RoxyonApiError ? err.message : String(err),\n config.application ? 'upload-failed' : 'create-failed',\n );\n }\n\n const url = config.public\n ? `https://${config.host}${config.folder ? `/${config.folder}` : ''}`\n : undefined;\n\n if (params.follow === false) {\n reporter?.step?.(`Build queued (revision ${revision})`);\n return {\n kind: 'app',\n ok: true,\n application: appId,\n status: 'building',\n revision,\n url,\n config,\n logs: [],\n };\n }\n\n return watch(roxyon, appId, {\n reporter,\n url,\n config,\n pollMs: params.pollMs ?? 3000,\n timeoutMs: params.timeoutMs ?? 10 * 60 * 1000,\n });\n}\n\nasync function watch(\n roxyon: Roxyon,\n appId: string,\n opts: {\n reporter?: DeployReporter;\n url?: string;\n config: ProjectConfig;\n pollMs: number;\n timeoutMs: number;\n },\n): Promise<DeployOutcome> {\n const started = Date.now();\n const seen = new Set<string>();\n const collected: string[] = [];\n let lastStatus = '';\n\n opts.reporter?.step?.('Building');\n while (true) {\n await sleep(opts.pollMs);\n\n let app: AccountApp | undefined;\n try {\n app = await roxyon.account.getApp(appId);\n } catch {\n /* transient */\n }\n if (!app) {\n if (Date.now() - started > opts.timeoutMs) break;\n continue;\n }\n\n const cfg = app.configRevision;\n const applied = app.appliedRevision;\n const status = app.status;\n if (status !== lastStatus) {\n opts.reporter?.step?.(`${status || 'pending'} (${applied}/${cfg})`);\n lastStatus = status;\n }\n\n try {\n for (const line of await roxyon.applications.logs(appId, 40)) {\n if (line && !seen.has(line)) {\n seen.add(line);\n collected.push(line);\n opts.reporter?.log?.(line);\n }\n }\n } catch {\n /* transient */\n }\n\n if (cfg <= applied && status === 'running') {\n opts.reporter?.step?.(`Live${opts.url ? ` — ${opts.url}` : ''}`);\n return {\n kind: 'app',\n ok: true,\n application: appId,\n status: 'running',\n revision: applied,\n url: opts.url,\n config: opts.config,\n logs: collected,\n };\n }\n if (status === 'failed') {\n return {\n kind: 'app',\n ok: false,\n application: appId,\n status: 'failed',\n error: (app.lastError || 'Deploy failed.').trim(),\n config: opts.config,\n logs: collected,\n };\n }\n if (Date.now() - started > opts.timeoutMs) break;\n }\n\n return {\n kind: 'app',\n ok: false,\n application: appId,\n status: 'timeout',\n error: 'Still building after the timeout — check `roxyon logs`.',\n config: opts.config,\n logs: collected,\n };\n}\n","import { spawn } from 'node:child_process';\nimport type { DeployReporter } from './deploy.js';\n\n/**\n * Default build-command runner: spawn a shell, stream output to the reporter.\n * Callers in a non-local context (a hosted server) can pass their own.\n */\nexport function runShellCommand(\n command: string,\n cwd: string,\n reporter?: DeployReporter,\n): Promise<number> {\n return new Promise((resolvePromise) => {\n const child = spawn(command, { cwd, shell: true, stdio: ['ignore', 'pipe', 'pipe'] });\n const pipe = (buf: Buffer) => {\n for (const line of buf.toString('utf8').split('\\n')) {\n if (line.trim()) reporter?.log?.(line);\n }\n };\n child.stdout?.on('data', pipe);\n child.stderr?.on('data', pipe);\n child.on('close', (code) => resolvePromise(code ?? 0));\n child.on('error', () => resolvePromise(127));\n });\n}\n","import { chmod, mkdir, readFile, rm, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { join } from 'node:path';\n\n/**\n * Stored login for Roxyon tooling — `~/.roxyon/config.json`, mode 0600. Written\n * by `roxyon login`; read by the CLI and the MCP server alike.\n */\nexport interface Credentials {\n sessionToken: string;\n refreshToken?: string;\n userId: string;\n email?: string;\n /** Preferred subscription (objectId / Name) when the account has several. */\n subscription?: string;\n savedAt: string;\n}\n\nexport interface Endpoints {\n apiUrl?: string;\n consoleUrl?: string;\n}\n\nexport function credentialsDir(): string {\n return join(homedir(), '.roxyon');\n}\nexport function credentialsPath(): string {\n return join(credentialsDir(), 'config.json');\n}\n\n/** Endpoint overrides from the environment (`ROXYON_API_URL`, `ROXYON_CONSOLE_URL`). */\nexport function endpointsFromEnv(): Endpoints {\n return {\n apiUrl: process.env.ROXYON_API_URL,\n consoleUrl: process.env.ROXYON_CONSOLE_URL,\n };\n}\n\n/** A token supplied out-of-band (CI, or an MCP host env). Skips the stored login. */\nexport function tokenFromEnv(): string | undefined {\n return process.env.ROXYON_TOKEN || undefined;\n}\n\nexport async function loadCredentials(): Promise<Credentials | undefined> {\n try {\n return JSON.parse(await readFile(credentialsPath(), 'utf8')) as Credentials;\n } catch {\n return undefined;\n }\n}\n\nexport async function saveCredentials(creds: Credentials): Promise<string> {\n const path = credentialsPath();\n await mkdir(credentialsDir(), { recursive: true, mode: 0o700 });\n await writeFile(path, `${JSON.stringify(creds, null, 2)}\\n`, { mode: 0o600 });\n await chmod(path, 0o600).catch(() => undefined);\n return path;\n}\n\nexport async function clearCredentials(): Promise<void> {\n await rm(credentialsPath(), { force: true });\n}\n"],"mappings":";AAAA,SAAS,UAAU,SAAS,YAAY;AAC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Y,QAAQ,IAAI;AAAA,EAC1B;AACF;AAGO,SAAS,eAAmC;AACjD,SAAO,QAAQ,IAAI,gBAAgB;AACrC;AAEA,eAAsB,kBAAoD;AACxE,MAAI;AACF,WAAO,KAAK,MAAM,MAAMF,UAAS,gBAAgB,GAAG,MAAM,CAAC;AAAA,EAC7D,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAEA,eAAsB,gBAAgB,OAAqC;AACzE,QAAM,OAAO,gBAAgB;AAC7B,QAAMD,OAAM,eAAe,GAAG,EAAE,WAAW,MAAM,MAAM,IAAM,CAAC;AAC9D,QAAME,WAAU,MAAM,GAAG,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA,GAAM,EAAE,MAAM,IAAM,CAAC;AAC5E,QAAM,MAAM,MAAM,GAAK,EAAE,MAAM,MAAM,MAAS;AAC9C,SAAO;AACT;AAEA,eAAsB,mBAAkC;AACtD,QAAM,GAAG,gBAAgB,GAAG,EAAE,OAAO,KAAK,CAAC;AAC7C;","names":["readFile","readdir","join","readFile","resolve","RUNTIMES","resolve","url","RUNTIMES","mkdir","readFile","writeFile","join"]}
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@roxyon/deploy-core",
3
+ "version": "0.1.0",
4
+ "description": "Shared deploy pipeline for Roxyon tooling — project detection, archiving, and the build/upload/poll orchestration used by @roxyon/cli and @roxyon/mcp.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.cjs",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.cjs"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "LICENSE"
20
+ ],
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/bea-technology/roxyon-devtools.git",
27
+ "directory": "packages/deploy-core"
28
+ },
29
+ "dependencies": {
30
+ "ignore": "^5.3.2",
31
+ "tar": "^7.4.3",
32
+ "@roxyon/api-client": "0.1.0"
33
+ },
34
+ "devDependencies": {
35
+ "@types/node": "^20.16.11",
36
+ "tsup": "^8.3.0",
37
+ "typescript": "^5.6.3",
38
+ "vitest": "^2.1.3"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "scripts": {
44
+ "build": "tsup",
45
+ "typecheck": "tsc --noEmit",
46
+ "test": "vitest run"
47
+ }
48
+ }